docker-gen aborting when starting application container
We are trying to use nginx to do load balancing. However, we noticed that when application containers are running but the application is not fully started yet, nginx is not aware of it and will route traffic to it. Thus, we thought your approach will meet our needs.
After doing the 1st command to run nginx in a shared drive, I issued this command and I saw the container started and running for docker-gen
docker run --volumes-from nginx
-v /var/run/docker.sock:/tmp/docker.sock:ro
-v /tmp/templates:/etc/docker-gen/templates
-t jwilder/docker-gen -notify-sighup nginx -watch -only-exposed /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
Next step, when doing the docker run command for the application, docker-gen aborted with this error message: template error: template: nginx.tmpl:116:28: executing "nginx.tmpl" at <dir "/etc/nginx/cert...>: error calling dir: open /etc/nginx/certs: no such file or directory
We are using a proxy server and has ssl certificate in our /etc folder. Do you have any documentation on what changes we can do in the nginx.tmpl that will resolve this problem ? Any assistance is highly appreciated.
I think you need to mount in your certs dir from the host to your docker-gen container at /etc/nginx/certs.
The dir template function is saying that dir does not exist: https://github.com/jwilder/docker-gen/blob/master/template.go#L367
Thank you so much for your quick response. I cloned your template and deleted all the codes that are using the certs and I got it to work. However, I noticed that when I started the first container where the application starts right away, everything works like a charm. But when I start the second container wherein it takes some time for the application to start, when I send message to the virtual host, the response time is very slow, it seems like it is waiting for the second application to start running even though it is actually sending the request to the first container. Is there any way for nginx to process the request right away while the 2nd container's application is still starting up ? I tried using the -wait parameter but it is complaining about invalid value, I put something like -wait 200ms:20, both in quotes and without quotes. Any help will be highly appreciated. Thank you so much for sharing your code with people like us who are just learning these new technology.
Sent from my iPad
On Mar 16, 2016, at 10:00 AM, Jason Wilder [email protected] wrote:
I think you need to mount in your certs dir from the host to your docker-gen container at /etc/nginx/certs.
The dir template function is saying that dir does not exist: https://github.com/jwilder/docker-gen/blob/master/template.go#L367
— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub
Never mind, I got it to run. I did not read properly, sorry about that. I took out the -watch parameter, did not read that -watch and -wait goes together.
I have a question about the -wait parameter. I observed that when I start a container, it waited the minimum time consistently before updating the default.conf, when is the maximum time used ?