【Vegas原创】docker containner挂掉,无法exec进入bash,如何修改文件的终极解决方法
原创
©著作权归作者所有:来自51CTO博客作者李济宏Amadeus的原创作品,请联系作者获取转载授权,否则将追究法律责任
场景:
Nginx在bash里面配置的时候挂掉了,然后docker start不起来,exec bash进不去,造成无法再改里面的文件了
解决方法:
1,docker ps –a 可以查到所有docker,包括没有运行的,找到containner ID
[root@hecs-29489 ~]# docker psa
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
35a903217fb7"/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 cproot-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
[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