Docker-nginx: Docs: clarify "daemon: off;"

Created on 6 Sep 2015  路  7Comments  路  Source: nginxinc/docker-nginx

Hi =) Just wanted to share this as i scratched my head a while on this issue.

In the https://hub.docker.com/_/nginx/ page, the reader is encouraged to add "daemon: off;" to their nginx.conf, in this text:

Be sure to include daemon off; in your custom configuration to ensure that Nginx stays in the foreground so that Docker can track the process properly (otherwise your container will stop immediately after starting)!

however in https://github.com/nginxinc/docker-nginx/blob/master/Dockerfile#L22 it is explicit set, which ends up in something like this

2015/09/06 14:13:48 [emerg] 1#1: "daemon" directive is duplicate in /etc/nginx/nginx.conf:4
nginx: [emerg] "daemon" directive is duplicate in /etc/nginx/nginx.conf:4

Most helpful comment

Please add in the documentation the right way to start nginx in a docker-entrypoint.sh. Lost hours figuring it out that need to write 'daemon off;' as a string param.

exec nginx -g 'daemon off;' "$@"

All 7 comments

Not sure which one should be closed.

Please add in the documentation the right way to start nginx in a docker-entrypoint.sh. Lost hours figuring it out that need to write 'daemon off;' as a string param.

exec nginx -g 'daemon off;' "$@"

@andrefreitas see https://github.com/deis/registry-proxy for a real-life example on how this image is used.

Specifically https://github.com/deis/registry-proxy/blob/master/rootfs/bin/boot

Docs PR is merged now (https://github.com/docker-library/docs/issues/772) :+1: :heart:

@tianon Yeah, but it's not how @andrefreitas suggested

Wanted to add that if you are running a command like docker run --name some-nginx -d -p 8080:80 nginx , you need to remove the -d and that should fix the problem. If you have -d in the master process command there is no amount of 'daemon off' that will turn it off.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

felixrabe picture felixrabe  路  6Comments

lrhazi picture lrhazi  路  3Comments

rokf picture rokf  路  5Comments

sandersaares picture sandersaares  路  6Comments

a-shink picture a-shink  路  3Comments