alex321
V2EX  ›  Docker

使用 Dockerfile 构建了一个镜像,独独最后的 CMD 不运行,如何破

  •  
  •   alex321 ·
    alexroyce315 · Nov 23, 2018 · 4310 views
    This topic created in 2802 days ago, the information mentioned may be changed or developed.
    使用了 supervisord 守护,也创建了目录 mkdir /var/log/supervisor,结果还是不运行。最后的一行命令如下:

    CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]

    从镜像创建容器,然后 docker attach 进去,执行 /usr/bin/supervisord -c /etc/supervisord.conf 是可以正常跑起来里面的服务的。

    求教 v2er 们该如何破。
    Supplement 1  ·  Nov 23, 2018
    使用 docker logs 查看。CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"] 没有日志。但容器启动不起来,attach 过去提示:You cannot attach to a stopped container, start it first。

    如果单纯使用 CMD ["/usr/bin/supervisord"] 会得到下面的结果:
    /usr/lib/python2.7/site-packages/supervisor/options.py:461: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
    'Supervisord is running as root and it is searching '
    /usr/lib/python2.7/site-packages/supervisor/options.py:461: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
    'Supervisord is running as root and it is searching '
    Unlinking stale socket /run/supervisord.sock
    3 replies    2018-11-23 23:02:02 +08:00
    fqzz
        1
    fqzz  
       Nov 23, 2018   ❤️ 1
    配置文件里面有 nodaemon 么? 没有的话,前台的 supervisord 退出后,container 就会被杀掉。
    alex321
        2
    alex321  
    OP
       Nov 23, 2018
    已经通过添加了 -n 参数跑起来了。

    @fqzz #1 原来如此,检查了下 supervisord.conf 的配置是 false,感谢感谢。
    mritd
        3
    mritd  
       Nov 23, 2018 via iPhone
    我建议你好好看看容器的理论知识,比如它适合什么样的场景,本质是什么
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1367 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 16:52 · PVG 00:52 · LAX 09:52 · JFK 12:52
    ♥ Do have faith in what you're doing.