Skip to content

Latest commit

 

History

History
151 lines (97 loc) · 2.68 KB

42_pause_container.md

File metadata and controls

151 lines (97 loc) · 2.68 KB

Pause a Container

Docker Documentation References:

docker pause

docker unpause

docker run

docker stop

docker rm

Intent

The intent of this kata is to understand how to pause a running container.

Overview

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

Kata Steps

Start a Container

Command

docker run -p 80:80 -d nginx:alpine

Output

/ # docker run -p 80:80 -d nginx:alpine
2848300c09f1ad4feb2cea39750ed346022301057f71bc42809367e1d179c478

Execute a command against the Container

Command

wget localhost

Output

/ # wget localhost
Connecting to localhost (127.0.0.1:80)
index.html           100% |*************************************************************************************************************|   612   0:00:00 ETA

Pause the Container

Command

docker pause $(docker ps -q)

Output

/ # docker pause $(docker ps -q)
2848300c09f1

Execute a command aginst the Container

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)

List the Containers

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

Unpause the Container

Command

docker unpause $(docker ps -aq)

Output

/ # docker unpause $(docker ps -aq)
2848300c09f1

Stop the Container

Command

docker stop $(docker ps -qa)

Output

/ # docker stop $(docker ps -qa)
2848300c09f1

Remove the Container

Command

docker rm $(docker ps -aq)

Output

/ # docker rm $(docker ps -aq)
2848300c09f1

Previous | Index | Next