Is it possible to suspend a docker container and save its state so that it can be resumed later?

10/21/2017

This would be similar to putting a computer into a sleep mode. FYI: I'm asking this in the context of managing containers using Kubernetes.

The reason for asking is that we would like to run many interactive jobs and want to suspend these jobs when users are not actively working on them so that resources can be released and used by other users.

-- Fabian
docker
gpu
kubernetes

1 Answer

10/21/2017

Yes, you can use docker stop and docker start commands. It would like you suspend pc.

All data produced inside container will be saved. But main process will receive SIGTERM signal. After docker start this process will be started again

Also take a look at docker pause command.

The docker pause command suspends all processes in the specified containers. On Linux, this uses the cgroups freezer. Traditionally, when suspending a process the SIGSTOP signal is used, which is observable by the process being suspended. With the cgroups freezer the process is unaware, and unable to capture, that it is being suspended, and subsequently resumed. On Windows, only Hyper-V containers can be paused.

-- Bukharov Sergey
Source: StackOverflow