Docker Flashcards
What are challenges that docker resolves?
1) Compatibility
2) Dependencies
How to check docker version?
docker version
Run hub.docker.com/whalesay
run docker.com/whalesay cowsay Boo
List all running containers
ps
Show all containers
ps -a
Stop running container
stop
Remove container permanently
rm
List all container images
images
Remove docker image
rmi (all dependent containers are removed)
Pull image without running a container
pull
Why is container in ‘exited’ state?
Container is run when underlying process is run, otherwise is not
Run sleep cmd on ubuntu
docker run ubuntu sleep 5
Execute a cmd on a running container
exec name-or-id cat /etc/hosts
Run in attached mode
run domain\centos
Run in detached mode
1) -d
2) run -d domain/centos
Attach container
attach name-id
What is difference between attached & detached container?
1) Attached: currently loaded to shell prompt
2) Detached: running in the background, not currently loaded to shell
Specify which version of a container to run with a TAG
docker run Ubuntu:17.04
Flag to run c7s in interactive mode
1) -i
2) docker run -i domain/centos
Flag to map host port to c7s port & run
1) -p host-port:c7s-port
2) docker run -p 80:5000 domain\centos
How to map a volume
1) -v host-dir:c7s-dir
2) docker run -v /opt/datadir:/var/lib/mysql mysql
Flags to run interactive & pseudo-TTY
docker run -it domain/centos
Map local port to port of container
docker run -p 80:5000 domain/centos
Get container info in JSON
docker inspect
Access container log
docker log name-or-id
Run c7 selected version with additional cmd
docker run ubuntu:17.10 cat /etc/release
What is a limiation of running container with specified cmd?
Lack of control of current terminal session until cmd stops