Rails server is still running in a new opened docker container

前端 未结 9 1350
面向向阳花
面向向阳花 2021-01-31 08:05

I want to deploy my rails project using Docker. So I use Docker-Compose. But I get one weird error message. When run docker-compose up(this contains db-container with postgresql

9条回答
  •  不知归路
    2021-01-31 08:34

    In your docker-compose.yml file, under the application container itself, you can either use:

    command: ["rm /your-app-path/tmp/pids/server.pid && bundle exec bin/rails s -p 3000 -b '0.0.0.0'"]

    or

    command: ["rm /your-app-path/tmp/pids/server.pid; foreman start"]

    the reason for either ";" or "&&" is that the latter will send an exit signal if rm fails to find the file, forcing your container to prematurely stop. the prior will continue to execute.

    why is this caused in the first place? the rational is that if the server (puma/thin/whatever) does not cleanly exit, it will leave a pid in the host machine causing an exit error.

提交回复
热议问题