Home  >  Q&A  >  body text

docker build 自动启动服务不生效

docker buill -t imagename .
CMD 自动开启 nginx 失败

我想大声告诉你我想大声告诉你2756 days ago746

reply all(3)I'll reply

  • 阿神

    阿神2017-04-26 09:04:26

    buill?

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-26 09:04:26

    Generally speaking, automatically starting certain processes is usually managed by supervisor. Please google for specific usage.

    If you want something simpler, you can try:
    (1) CMD ["nginx", "-g", "daemon off;"], mainly used when docker run is required -d xxx;CMD ["nginx", "-g", "daemon off;"], 主要用在需要 docker run -d xxx 的情况;
    (2)或写一个脚本 run.sh, 然后 CMD ["path/to/run.sh"](2) or write a script run.sh, and then CMD ["path/to/run.sh"]

    Because you didn’t provide any other specific information, I don’t know what your nginx will return after failure, so I can only analyze it here.
    I am a citizen or above, and I mainly want to hear what is said later. Pass!

    reply
    0
  • PHPz

    PHPz2017-04-26 09:04:26

    Add CMD nginx to the Dockerfile. Note that if there are multiple CMDs, only the last one is valid.
    Build to generate the image and then run it.
    docker run -d image. That’s it.

    reply
    0
  • Cancelreply