Question: How to Pause and Resume running containers on docker host?
This post will help to know about pausing and resuming any running containers on the Docker host.
Let’s first start the docker container “memory_test” on the docker host.
# docker start memory_test memory_test
To stop the pause the docker container:
# docker pause memory_test memory_test
Verify the state of docker container using “docker ps”:
# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e6c2db30aa3f mytd/httpd:v2 "/bin/sh -c '/usr/sb…" 15 minutes ago Up 11 seconds (Paused) 80/tcp memory_test
You can also try connecting to the container. It should give you below error:
# docker exec -it memory_test bash Error response from daemon: Container memory_test is paused, unpause the container before exec <<<< container is paused , you can not connect .
Run the below command to resume or unpause the container.
# docker unpause memory_test
Verify the state of the docker container again.
# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e6c2db30aa3f mytd/httpd:v2 "/bin/sh -c '/usr/sb…" 17 minutes ago Up 2 minutes 80/tcp memory_test
Now you can connect to container again via docker exec command .
# docker exec -it memory_test bash bash-4.1# uname -a Linux e6c2db30aa3f 4.14.35-1818.3.3.el7uek.x86_64 #2 SMP Mon Sep 24 14:45:01 PDT 2018 x86_64 x86_64 x86_64 GNU/Linux
The container is connected and commands also work fine inside containers.