managing containers

port mapping

Launching Voteapp Frontend

 docker        run      -idt      -p   80      microsoft/dotnet-samples:aspnetapp

list container

docker container ps 
CONTAINER ID        IMAGE                                COMMAND                  CREATED             STATUS              PORTS                   NAMES
4ae023c7b5de        microsoft/dotnet-samples:aspnetapp   "dotnet aspnetapp.dll"   4 minutes ago       Up 4 minutes        0.0.0.0:54376->80/tcp   demo

80

32768

32769

docker host

mac/win

80

port mapping

docker container port <container id/name>

http://docker_host_ip:port

To access web app

container operations

renaming

docker container rename  <container id/name> app

SHOW PROCESSes

docker container top app

inspect

docker container inspect app

See if you could find the 

  • logpath
  • mount points
  • ip address

copying files

echo This is a sample text file > sample.txt
docker cp sample.txt vote:/opt/
docker cp vote:app .
docker diff vote
docker diff stats
  • A : Added
  • C : Changed
  • D : Deleted

Limiting resources

run stats

docker container stats

(^c to exit)

docker container stats --no-stream=true 
 

stats command is based on cgroups.  cgroups provide accounting of resources in addition to setting resource limits

Updating memory

 docker container inspect demo | systeminfo |find "Available Physical Memory"

docker container stats --no-stream=true
docker update --memory 400M  --memory-swap -1 app

docker container stats --no-stream=true

Limiting resources at launch


docker container stats 

Open a new terminal and keep the following command running to check stats


docker run -d --name st-01 --cpu-shares 512 microsoft/dotnet-samples:aspnetapp stress --cpu 1

docker run -d --name st-02 --cpu-shares 1024 microsoft/dotnet-samples:aspnetapp stress --cpu 1

docker run -d --name st-03 --cpu-shares 1024 microsoft/dotnet-samples:aspnetapp stress --cpu 1

docker run -d --name st-04 --cpu-shares 512 microsoft/dotnet-samples:aspnetapp stress --cpu 1

Launch containers with --cpu-shares

docker container stop st-01 st-02 st-03 st-04


docker container ps -a 


docker system df


docker container prune

Cleaning Up

Made with Slides.com