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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • 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. How to Map Static IP to your Domain (with GoDaddy example)
  2. Puppet Server’s Resources Cheat Sheet with Examples
  3. How to Use user-defined Functions in awk
  4. How to use command line shell functions in Linux
  5. How to change the default IP address of docker bridge
  6. Understanding “docker stats” Command Output
  7. Examples of “shift” Command in Shell Scripts
  8. How to List / Start / Stop / Delete docker Containers
  9. Strings and Variables in Python
  10. How to Find and Delete Empty Directories and Files in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • grpck command – Remove corrupt or duplicate entries in the /etc/group and /etc/gshadow files.
  • xxd command – Expressed in hexadecimal form
  • sesearch: command not found
  • macof: command not found

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright