Docker Documentation References:
The intent of this kata is to learn how to pause a running container. This kata is essentially the same as the Pause a Container kata.
In this exercise we will start a container, execute a command against the container, pause the container, execute another command against the container, list the running containers, kill the container, and then remove the container
Command
docker run -p 80:80 -d nginx:alpine
Output
/ # docker run -p 80:80 -d nginx:alpine
2848300c09f1ad4feb2cea39750ed346022301057f71bc42809367e1d179c478
Command
wget localhost
Output
/ # wget localhost
Connecting to localhost (127.0.0.1:80)
index.html 100% |*************************************************************************************************************| 612 0:00:00 ETA
Command
docker pause $(docker ps -q)
Output
/ # docker pause $(docker ps -q)
2848300c09f1
Command
wget localhost
Output
/ # wget localhost
Connecting to localhost (127.0.0.1:80)
^C
Note that this command fails because the container is paused, it is not responding to the
wget
call. (If you get tired of waiting you can hit Ctrl-C)
Command
docker ps -a
Output
/ # docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2848300c09f1 nginx:alpine "nginx -g 'daemon ..." About a minute ago Up About a minute (Paused) 0.0.0.0:80->80/tcp quizzical_haibt
Command
docker unpause $(docker ps -aq)
Output
/ # docker unpause $(docker ps -aq)
2848300c09f1
Command
docker stop $(docker ps -qa)
Output
/ # docker stop $(docker ps -qa)
2848300c09f1
Command
docker rm $(docker ps -aq)
Output
/ # docker rm $(docker ps -aq)
2848300c09f1