DEV Community

Ajay Singh
Ajay Singh

Posted on

Keep Docker alive during docker daemon downtime

When the docker daemon terminates by default it shutdowns the running docker containers. From Docker Engine 1.12, you can configure the daemon so that containers remain running even if the daemon becomes unavailable.
This functionality is named is live restore. The live restore option helps reduce container downtime due to daemon crashes, planned outages, or upgrades.

How do we enable live restore?

There are two ways to enable live restore

  • Add the configuration to the daemon configuration file. On Linux, this defaults to /etc/docker/daemon.json

    Use the following JSON to enable live-restore.

      {
         "live-restore": true
       }
    

    you can restart the docker daemon now. If you are using systemd, then use the command systemctl reload docker.

  • you can also start the dockerd process manually with the --live-restore flag.

Impact of live restore on running containers

If the daemon is down for a long time, running containers may fill up the FIFO log the daemon normally reads. A full log blocks containers from logging more data. The default buffer size is 64K. If the buffers fill, you must restart the Docker daemon to flush them.

On Linux, you can modify the kernel’s buffer size by changing /proc/sys/fs/pipe-max-size.

Live restore and swarm mode

The live restore option only pertains to standalone containers, and not to swarm services. Swarm services are managed by swarm managers. If swarm managers are not available, swarm services continue to run on worker nodes but cannot be managed until enough swarm managers are available to maintain a quorum.

Live restore during upgrades

Live restore supports keeping containers running across Docker daemon upgrades, though this is limited to patch releases and does not support minor or major daemon upgrades.

If you skip releases during an upgrade, the daemon may not restore its connection to the containers. If the daemon can’t restore the connection, it cannot manage the running containers and you must stop them manually.

Live restore upon restart

The live restore option only works to restore containers if the daemon options, such as bridge IP addresses and graph driver, did not change. If any of these daemon-level configuration options have changed, the live restore may not work and you may need to manually stop the containers.

Latest comments (0)