• 【Vegas原创】docker containner挂掉,无法exec进入bash,如何修改文件的终极解决方法


    场景:

    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
    喜欢请赞赏一下啦^_^
  • 相关阅读:
    JS基本语法---while循环---练习
    JS基本语法---while循环
    JS基础语法---分支语句总结
    Python开发坦克大战
    基于Python的face_recognition库实现人脸识别
    10个Python 初学者必知编码小技巧
    论如何用python发qq消息轰炸虐狗好友
    Python + Selenium +Chrome 批量下载网页代码修改【新手必学】
    Python爬取mc皮肤【爬虫项目】
    Python 分发包中添加额外文件【新手必学】
  • 原文地址:https://www.cnblogs.com/amadeuslee/p/15079739.html
Copyright © 2020-2023  润新知