Restart nginx container when linked django container is recreated

Hello,

I have a Django container serving a web app using gunicorn. This Django container is linked to a nginx container which acts as a proxy. The setup works fine.

From time to time I update my Django app and I recreate the container. When I do this, the nginx container loses connection and does not forward the requests to the Django container any more. I tried stopping and starting the nginx container but the link is not recovered. The only alternative is to delete the nginx container and recreate it.

Is there an easier way to recover the link without recreating the nginx container.

Thanks!
Rares

Hi,

First of all, I am running an instance of Ghost (blogging) in a similar fashion on DigitalOcean. In my case I have an nginx container which proxies traffic to the Ghost application in a different container. In my case for some reason or the other, I have to restart the ghost container (eg. to pickup a new theme by ghost) and just a restart of nginx will fix the links. The secret for this to work in my opinion being the container ID of ghost remains the same on restarts (not destroying the container and recreating)

I did couple of test runs of containers today after reading your question and found that when the target container ID changes , a restart to the proxying container completely ignores the links. I checked this with Docker inspect too.

So for you to get things work, try to design the container so that you need not recreate the container each time. In my case my application is attached to the container as a volume. The same method will help you is what I believe.

Will wait for some expert to comment on this issue.

Regards