• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Pause and Resume Docker Containers

By admin

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.

Filed Under: DevOps, Docker

Some more articles you might also be interested in …

  1. Beginners Guide to Using “trap” to Catch Signals and Handle Errors in Shell Script
  2. How To Access Kubernetes Dashboard Externally
  3. Bash if loop examples (if then fi, if then elif fi, if then else fi)
  4. How to Write Ansible Playbook and run it using the ansible-playbook command
  5. How to backup and restore Docker containers
  6. Using Loops (while, for) in awk scripts
  7. How to use shell aliases in Linux
  8. How to Disable Docker Process and docker0 Interface on CentOS/RHEL
  9. How to use command redirection under Linux
  10. Introduction to sed (Stream Editor) : Useful sed Command Examples

You May Also Like

Primary Sidebar

Recent Posts

  • What are Command Rules in oracle Database
  • Using Rule Sets in Oracle Database Vault
  • How Realms Work in Oracle Database Vault
  • How to use Privilege Analysis in Oracle Database
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary