docker-gen icon indicating copy to clipboard operation
docker-gen copied to clipboard

Cannot reload template file?

Open citymonitor opened this issue 7 years ago • 9 comments

Hi there,

I came across this question a few times, but no solution helped. I have the following setup: https://gist.github.com/citymonitor/93c4d2faeeef2e9fdd2c517fc3e071e0

It's all running fine. But I don't get how to reload the config (recreate default.conf from nginx.tmpl). I tried: docker-compose up -d --force-recreate --build but this didn't help.

Can anyone tell me how to do this?

citymonitor avatar Dec 14 '18 13:12 citymonitor

docker container kill -s HUP nginx-gen

buchdag avatar Dec 14 '18 14:12 buchdag

@buchdag thanks a lot but how do I verify it is actually reloaded or how do I check for errors? It still seems to be the same

citymonitor avatar Dec 14 '18 14:12 citymonitor

docker container logs nginx-gen

If docker-gen picked up changes that impact the generated default.conf you'll see an entry like this one: 2018/01/01 12:00:00 Generated '/etc/nginx/conf.d/default.conf' from X containers

If you see 2018/01/01 12:00:00 Contents of /etc/nginx/conf.d/default.conf did not change [...] it means that the change you made were not picked up by docker-gen or by the template your are using.

docker-gen won't generate the same file over again if there are no changes.

buchdag avatar Dec 14 '18 14:12 buchdag

@buchdag what exactly impacts default.conf? Does it recognize if the template file changes?

citymonitor avatar Dec 20 '18 12:12 citymonitor

Your change to the template file have to result in changes to the default.conf file in your specific Docker environment.

For instance let's say you add some code the template file that generated additional configuration lines according to the value of a container environment variable called WHATEVER if and only if it is set. If you don't set the WHATEVER environment variable on any container, your change on the template file won't result in changes to the generated file.

No one but you can tell wether a change in the generated file should occur with a specific template file on your specific Docker environment with your own containers. And don't forget that docker-gen has option (like -only-exposed) that further restrain the containers it picks up.

buchdag avatar Dec 20 '18 13:12 buchdag

@buchdag thanks a lot I will try that! I've added an additional location entry in the template and it did not pick up anything.

Just one more thing: is it possible to add an additional, custom, static config to this running nginx instance somehow?

citymonitor avatar Dec 21 '18 08:12 citymonitor

Your question is specific to jwilder/nginx-proxy, you should read that repo's doc and ask your question there if the answer is not in the doc.

buchdag avatar Dec 21 '18 09:12 buchdag

Thank you, I've posted in the group with the exact problem I'm trying to solve: https://groups.google.com/forum/#!topic/nginx-proxy/bQ1xvRElJ4k

citymonitor avatar Dec 21 '18 09:12 citymonitor

@buchdag one more question, if I simply change a variable like - LETSENCRYPT_HOST=domain1.com to: - LETSENCRYPT_HOST=domain1.com,domain2.com

the file is not reloaded. How can I reliably force this?

solars avatar Jan 07 '19 13:01 solars