Custom nginx container exits immediately when part of docker-compose

后端 未结 4 1238
自闭症患者
自闭症患者 2021-01-30 17:34

I\'m trying to learn how to use docker compose with a simple setup of an nginx container that reroutes requests to a ghost container. I\'m using the standard ghost image but hav

4条回答
  •  盖世英雄少女心
    2021-01-30 18:11

    The CMD in your Dockerfile should start a process which needs to run in foreground. The command service nginx start runs the process in deamon mode and thus your container exits cleanly because the service command exits.

    Use the following CMD ["nginx", "-g", "daemon off;"] to start nginx (taken from official image) and it should work correctly.

提交回复
热议问题