Jq修改docker-daemon.json开启关闭live-restore
来自三线的随记
use jq tool to enable or disable docker live-restore feature
enable
cat <<< $( jq '. + {"live-restore": true}' /etc/docker/daemon.json ) > /etc/docker/daemon.json jq <<< $(cat /etc/docker/daemon.json ) > /etc/docker/daemon.json
#jq '. + {"live-restore": true}' /etc/docker/daemon.json systemctl reload docker docker info | grep -i live
disable
jq '. + {"live-restore": false}' /etc/docker/daemon.json kill -SIGHUP $(pidof dockerd) docker info | grep Live
Other matters requiring attention
对于挂载了/var/run/docker.sock的容器,需要手动重启 (挂载的是目录的话不会有这个问题)
docker挂载文件的机制是绑定主机上该文件的 inode。
当docker-engine热重启,docker.sock文件的inode值会改变,所以挂载会失效
Workaround
查看该主机上直接挂载 docker.sock 的容器
docker inspect $(docker ps -q)|grep 'Source.*docker.sock\|Name": "/'|grep sock -B1|grep Name
重启之
more examples
https://gist.github.com/joar/776b7d176196592ed5d8