Docker's "live restore" feature is designed to improve the behaviour of Docker daemon restarts. When the live restore feature is enabled, the Docker daemon attempts to keep containers running during daemon restarts or upgrades. This means that if the Docker daemon is stopped or restarted, the containers that were running before the restart will attempt to stay running after the daemon restarts.
By default, Docker stops and restarts containers when the Docker daemon is restarted, which can cause a brief interruption in the availability of services. Live restore minimizes this downtime by allowing containers to keep running during the daemon restart process.
To enable live restore, you can set the "live-restore" option in the Docker daemon configuration file (usually located at /etc/docker/daemon.json)
Let's evaluate this feature before enabling 'live-restore' and after enabling the 'live-restore' feature. We'll observe the difference it makes when running a Docker container.
Before enabling "live-restore"
1.Run the Nginx container in detachable mode
[root@siddhesh ~]# docker container run -dt nginx
604abfc32675aed376bd25bb136d4963ece0e48b352100c92e7295279e69ab85
[root@siddhesh ~]#
2.Verify running container
[root@siddhesh ~]# docker container ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
604abfc32675 nginx "/docker-entrypoint.…" 4 seconds ago Up 4 seconds 80/tcp vigorous_varahamihira
[root@siddhesh ~]#
3.Restart docker service
[root@siddhesh ~]# systemctl restart docker
4.Re-verify the status of the running container
[root@siddhesh ~]# docker container ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@siddhesh ~]#
As you can see, the running Docker instance was terminated when we restarted the Docker service. To avoid this, let's enable the 'live-restore' feature in Docker.
How to enable "live-restore" in Docker.
1.Create a new file '/etc/docker/daemon.json' if it does not exist and add the following parameters.
[root@siddhesh ~]# cat /etc/docker/daemon.json
{
"live-restore": true
}
[root@siddhesh ~]#
2.Restart the docker service to get this set permanently.
[root@siddhesh ~]# systemctl restart docker
After enabling "live-restore"
1.Run the Nginx container in detachable mode
[root@siddhesh ~]# docker container run -dt nginx
eed85da0bf3be60ce4bd8b7f02b99886dc6c876b0ddc0583eafdbed7c6491996
[root@siddhesh ~]#
2.Verify running container
[root@siddhesh ~]# docker container ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
eed85da0bf3b nginx "/docker-entrypoint.…" 4 seconds ago Up 3 seconds 80/tcp adoring_leakey
[root@siddhesh ~]#
3.Restart docker service
[root@siddhesh ~]# systemctl restart docker
4.Re-verify the status of the running container
[root@siddhesh ~]# docker container ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
eed85da0bf3b nginx "/docker-entrypoint.…" 9 seconds ago Up 8 seconds 80/tcp adoring_leakey
[root@siddhesh ~]#
As you can see in the output above, the container is still running even after restarting the Docker service. This can be particularly useful in production environments where continuous uptime is crucial.
Here are some points to be aware of before enabling Docker live-restore :
Resource Intensiveness:
Enabling live restore might increase resource usage, as Docker needs to maintain the state of running containers during daemon restarts. This could potentially impact system performance, especially in environments with limited resources.
Application Compatibility:
Not all applications may behave well with live restore. Some applications might not gracefully handle the temporary pause or interruption in communication that occurs during a Docker daemon restart.
State Consistency:
While Docker attempts to maintain the running state of containers, there could be scenarios where the state consistency is compromised. For example, if a container is in the middle of a critical operation when the daemon restarts, ensuring the correctness of the container's state can be challenging.
Debugging Complexity:
Debugging issues related to live restore might be more complex compared to standard container restarts. Troubleshooting unexpected behaviours during daemon restarts may require a deeper understanding of Docker internals.
Compatibility with Swarm Mode:
In Docker Swarm mode, live restore might not work seamlessly in all situations. Swarm mode introduces additional complexities, and certain configurations or network setups may not fully support live restore.
Dependency on Container Runtime:
The effectiveness of live restore can be influenced by the container runtime and underlying infrastructure. Different runtimes or container orchestration platforms may have varying degrees of support for live restore.
Testing and Validation:
It's essential to thoroughly test the live restore feature in a staging or development environment before enabling it in production. This ensures that your specific application workloads behave as expected.
Comments