By default, when the Docker daemon terminates, it shuts down running containers . However, we can configure the daemon so that the container will still run if the daemon is unavailable. This feature is called live recovery. The live restore option helps reduce container downtime due to daemon crashes, scheduled outages, or upgrades.
Docker official related detailed documentation: https://docs.docker.com/config/containers/live-restore/
specific method:
1. Add the configuration to the daemon configuration file. On Linux, the default configuration file is /etc/docker/daemon.json
vim /etc/docker/daemon.json { "live-restore": true }
Before restarting docker, you need to restart the docker process
docker start mysql57
docker start cadvisor
docker start node-exporter
docker start prom/node-exporter
vim /etc/docker/daemon.json
{
"registry-mirrors": ["http://hub-mirror.c.163.com"],
"insecure-registries": ["http://192.168.1.249:8086","https://192.168.1.249:16443"],
"live-restore": true
}
2.Docker reload configuration (docker will not be restarted)
重启或给dockerd发送 SIGHUP信号,dockerd收到信号后会reload配置
systemctl reload docker or send signal kill -SIGHUP $(pidof dockerd)
3. Check whether the above configuration is successful
docker info | grep -i live
4. Restart Docker, the container will not stop when you restart Docker at this time
systemctl restart docker
5. docker ps view