Operating DOcker 

docker 

Management Commands:
  container   Manage containers
  image       Manage images
  network     Manage networks
  node        Manage Swarm nodes
  plugin      Manage plugins
  secret      Manage Docker secrets
  service     Manage services
  stack       Manage Docker stacks
  swarm       Manage Swarm
  system      Manage Docker
  volume      Manage volumes
docker 

docker version 

docker -v 

docker system info 

Launching Container

image

app

docker
container
run
alpine:3.4
uptime

(environment)

image format

registry.docker.io

registry

namespace

repository

tag

/user
/ubuntu
:16.04

Launching Container

docker
container
run
alpine:3.4
uptime
  • image pull
  • container create
  • container attach
  • network connect
  • container start
  • container die
  • network disconnet

Events

what happened to the container? 

docker   ps 

docker   ps -l

Docker containers last only till

the program you started with it

lasts. It will stop immediately

after the program exits.

docker
container
run
alpine:3.4
free
docker
container
run
alpine:3.4
uname -a
docker
container
run
alpine:3.4
ps aux

listing containers

docker container ps

docker container ps -l 

docker container ps -n 2 

docker container ps -a

interactive mode

docker container run  -i -t opensuse/leap:15 bash

interactive

allocate TTY

open shell

Namespaced

non namespaced

running Commands inside container
cat /etc/issue

ps aux 

ifconfig

hostname
uptime 

uname -a 

cat /proc/cpuinfo

date

making containers persist

docker container run 

detach

image

app/program

-idt
schoolofdevops/loop
program

(persistent)

Checking Logs

docker container ps 

docker container logs <container id/name>

docker container logs -f  <container id/name>
docker system info 

[check for plugins/log]

Ref: https://docs.docker.com/config/containers/logging/configure/

RUNNING COMMANDS

docker container ps 

docker container exec  <container id>  ps aux


docker container exec  -it  <container id>  sh 

launching a sles 15 container


docker pull registry.suse.com/suse/sle15

docker image ls

docker container run -idt --name sles15 registry.suse.com/suse/sle15 bash

docker exec -it sles15 bash

[try running  suse linux  commands]

exit 
docker container run  -idt -P  schoolofdevops/vote

port mapping

port mapping

list container

docker container ps 
CONTAINER ID        IMAGE                                   COMMAND                  CREATED             STATUS              PORTS                                                              NAMES
f6ce11cb529b        schoolofdevops/vote                     "gunicorn app:app ..."   54 seconds ago      Up 52 seconds       0.0.0.0:32776->80/tcp                                              cranky_poitras

80

32768

32769

docker host

mac/win

80

docker container port <container id/name>

http://docker_host_ip:port

To access web app

renaming

docker container rename  <container id/name> vote

inspect

docker container inspect vote

See if you could find the 

  • logpath
  • mount points
  • ip address

copying files

touch localfile
docker container cp localfile vote:/opt/
docker container 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 vote | grep -i memory

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

docker container stats --no-stream=true
[CPU Shares]

docker run -d --cpu-shares 1024 schoolofdevops/stresstest stress --cpu 2

docker run -d --cpu-shares 1024 schoolofdevops/stresstest stress --cpu 2

docker run -d --cpu-shares 512 schoolofdevops/stresstest stress --cpu 2

docker run -d --cpu-shares 512 schoolofdevops/stresstest stress --cpu 2

docker run -d --cpu-shares 4096 schoolofdevops/stresstest stress --cpu 2


[CPUs]

docker run -d --cpus 0.2 schoolofdevops/stresstest stress --cpu 2

Launch containers with --cpu-shares

controlling CPU

disk managemnt

docker system df

docker [ system | container | image ]  prune 

stop & remove

docker container  stop <container id>

docker container rm <container id>
Made with Slides.com