V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
alex321
V2EX  ›  Docker

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

  •  
  •   alex321 ·
    alexroyce315 · 2018-11-23 11:09:32 +08:00 · 3635 次点击
    这是一个创建于 1953 天前的主题,其中的信息可能已经有所发展或是发生改变。
    使用了 supervisord 守护,也创建了目录 mkdir /var/log/supervisor,结果还是不运行。最后的一行命令如下:

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

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

    求教 v2er 们该如何破。
    第 1 条附言  ·  2018-11-23 12:05:14 +08:00
    使用 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 条回复    2018-11-23 23:02:02 +08:00
    fqzz
        1
    fqzz  
       2018-11-23 14:27:58 +08:00   ❤️ 1
    配置文件里面有 nodaemon 么? 没有的话,前台的 supervisord 退出后,container 就会被杀掉。
    alex321
        2
    alex321  
    OP
       2018-11-23 14:38:19 +08:00
    已经通过添加了 -n 参数跑起来了。

    @fqzz #1 原来如此,检查了下 supervisord.conf 的配置是 false,感谢感谢。
    mritd
        3
    mritd  
       2018-11-23 23:02:02 +08:00 via iPhone
    我建议你好好看看容器的理论知识,比如它适合什么样的场景,本质是什么
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2523 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 15:43 · PVG 23:43 · LAX 08:43 · JFK 11:43
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.