NGINX & Consul-Template in Docker NGINX & Consul-Template in Docker docker docker

NGINX & Consul-Template in Docker


Consul Template will exit once the script it runs after writing returns a non-zero exit code. See here for the documentation.

The documentation suggests to put a || true just after the restart (or reload) command. This will keep Consul Template running independent of the exit code.

You could consider wrapping the restart in its own shell script that first tests the configuration (with nginx -t) before triggering a reload. You could even move the initial start of nginx to this script as it only makes sense to start nginx once the first (valid) configuration has been written?!