修改已运行 docker 容器的端口绑定、重启策略

参考:https://www.cnblogs.com/shijf/p/10386193.html

https://www.cnblogs.com/myfqm/p/13086125.html

https://www.cnblogs.com/zhuochong/p/10070516.html

1、停止容器,然后找到容器的对应配置文件:/var/lib/docker/containers/[hash_of_the_container]/hostconfig.json

2、修改后保存(如修改端口绑定:PortBindings、重启策略:RestartPolicy)

3、重启 docker:systemctl restart docker

4、通过 docker inspect [hash_of_the_container] 命令可以查看当前容器的配置

5、通过 docker update --restart always [hash_of_the_container] 可以直接修改容器的重启策略


输了你,赢了世界又如何...
原文地址:https://www.cnblogs.com/xwgli/p/14450230.html