Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I suspend and then resume a Docker container?

Tags:

docker

I would like to suspend a Docker container and resume later. How can this be done? By suspending I mean that it should save the state of ongoing process (e.g. video encoding) and then resume it back at any time.

like image 295
Mykola Pavlov Avatar asked Apr 16 '13 22:04

Mykola Pavlov


People also ask

How do you pause and resume a docker container?

To resume Docker Desktop, click either the Resume button in the menu or type any Docker CLI command in your terminal. To try out this feature on Docker Desktop 4.2, navigate to the whale menu and click the 'Pause' button.

Is it possible to pause a docker container?

Pause Container If we want to pause the processes running inside the container, we can use the “docker pause” command. To unpause the container, use “docker unpause” command.

How do I stop docker container temporarily?

To stop one or more running Docker containers, you can use the docker stop command. The syntax is simple: $ docker stop [OPTIONS] CONTAINER [CONTAINER...]

How do I stop and restart a container?

Your answerThe main process inside the container will receive SIGTERM, and after a grace period, SIGKILL. This will stop a running container. This would restart the container.


2 Answers

As of Version 0.12.0, Docker supports PAUSE and UNPAUSE commands to pause and resume containers using cgroup freezer.

like image 64
David Gageot Avatar answered Oct 19 '22 20:10

David Gageot


AFAIK right now it can't be done with pure docker but lxc supports that. I've play around little bit with docker and confirmed that this can be done with lxc-freeze -n <containtr.id> and to resume operations lxc-unfreeze -n <container.id> But in v0.2.0 docker ps gives you only shorten containter id even with -notrunc and lxc-ls output is empty on my system (strange, need to read more about it, as docker uses plain lxc-start with params so lxc-ps should print this). I found full container id with lxc-ps. It would be nice to add docker freeze command. Maybe it's time for me to learn some go :)

like image 21
odk Avatar answered Oct 19 '22 19:10

odk