通过 docker rm -f
强制删除容器后依然会重启,docker update --restart=no
后再强制删除,问题依旧
通过 docker inspect 查看 RestartPolicy 名称为空
"RestartPolicy": {
"Name": "",
"MaximumRetryCount": 0
}
终于破案了!通过 /var/lib/docker/containers/<container_id>/config.v2.json
查看这个容器的配置文件
"Service": {
"ID": "k4rbtqzzlsognzwacahxi4od1",
"Name": "compassionate_blackburn",
"Aliases": {},
"VirtualAddresses": {
"luxvrw4t59zlxyqs365z0a32d": {
"IPv4": "x.x.x.x",
"IPv6": ""
},
"nftbre0dphq27shiu2v2pfsom": {
"IPv4": "x.x.x.x",
"IPv6": ""
}
},
"ExposedPorts": null
},
发现 service 信息时才恍然大悟,这台服务器是 docker swarm manager 节点,当时通过 service 方式部署了这个额外的 memcached 容器,就是下面的第一行
k4rbtqzzlsog compassionate_blackburn replicated 1/1 memcached:latest
2s5yt92x0ajt memcached_service replicated 1/1 memcached:latest
通过 service 删除命令删除就可以了
docker service rm k4rbtqzzlsog
Ensuring Containers Are Always Running with Docker's Restart Policy
– dudu 5天前