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
image
app
docker
container
run
alpine:3.4
uptime
(environment)
registry.docker.io
registry
namespace
repository
tag
/user
/ubuntu
:16.04
docker
container
run
alpine:3.4
uptime
image pull
container create
container attach
network connect
container start
container die
network disconnet
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
docker container ps
docker container ps -l
docker container ps -n 2
docker container ps -a
docker container run -i -t opensuse/leap:15 bash
interactive
allocate TTY
open shell
running Commands inside container
cat /etc/issue
ps aux
ifconfig
hostname
uptime
uname -a
cat /proc/cpuinfo
date
docker container run
detach
image
app/program
-idt
schoolofdevops/loop
program
(persistent)
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/
docker container ps
docker container exec <container id> ps aux
docker container exec -it <container id> sh
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
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
docker container rename <container id/name> vote
docker container inspect vote
See if you could find the
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
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
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
docker system df
docker [ system | container | image ] prune
docker container stop <container id>
docker container rm <container id>