场景:
Nginx在bash里面配置的时候挂掉了,然后docker start不起来,exec bash进不去,造成无法再改里面的文件了
解决方法:
1,docker ps –a 可以查到所有docker,包括没有运行的,找到containner ID
[root@hecs-29489 ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 35a903217fb7 nginx "/docker-entrypoint.…" 11 days ago Exited (1) 9 minutes ago nginx 43030fc53a87 wordpress "docker-entrypoint.s…" 12 days ago Up 12 days 0.0.0.0:81->80/tcp, :::81->80/tcp wpJesus e03c1b470c42 mysql "docker-entrypoint.s…" 12 days ago Up 12 days 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp mysql
2,用docker CP命令,往出来拷文件,改好后,再拷进去 。
[root@hecs-29489 ~]# docker cp 35a903217fb7:/etc/nginx/conf.d/default.conf /root [root@hecs-29489 ~]# cd /root [root@hecs-29489 ~]# ls default.conf HostGuardAgent_Linux64_V1.12.50.rpm.sha256 hostguard_setup_config.dat HwAgentInstall_64.sh scs1627613284839_weyomusic.com_server.crt scs1627613284839_weyomusic.com_server.key [root@hecs-29489 ~]# vi default.conf [root@hecs-29489 ~]# docker cp default.conf 35a903217fb7:/etc/nginx/conf.d/ [root@hecs-29489 ~]# docker start nginx nginx [root@hecs-29489 ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 35a903217fb7 nginx "/docker-entrypoint.…" 11 days ago Up 1 second 0.0.0.0:80->80/tcp, :::80->80/tcp nginx 43030fc53a87 wordpress "docker-entrypoint.s…" 12 days ago Up 12 days 0.0.0.0:81->80/tcp, :::81->80/tcp wpJesus e03c1b470c42 mysql "docker-entrypoint.s…" 12 days ago Up 12 days 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp mysql
版权声明:程序员胖胖胖虎阿 发表于 2022年9月9日 下午6:32。
转载请注明:【Vegas原创】docker containner挂掉,无法exec进入bash,如何修改文件的终极解决方法 | 胖虎的工具箱-编程导航
转载请注明:【Vegas原创】docker containner挂掉,无法exec进入bash,如何修改文件的终极解决方法 | 胖虎的工具箱-编程导航
相关文章
暂无评论...