Docker Community Forums

Share and learn in the Docker community.

Need to restart docker daemon between stop and restart of linked containers

docker

(Powergnom) #1

Hello all,

I am running two docker containers, one with a database server (postgres) and one with web server (tomcat) that accesses the database. Both containers are started with --detach and --restart unless-stopped:
docker run --detach --restart unless-stopped --name “postgres” …
docker run --detach --restart unless-stopped --link “postgres:postgres” --name “tomcat” …

This seems to work fine and survives reboots as intended. However, if I stop and restart both containers by
docker stop tomcat
docker rm tomcat
docker stop postgres
docker rm postgres
docker run --detach --restart unless-stopped --name “postgres” …
docker run --detach --restart unless-stopped --link “postgres:postgres” --name “tomcat” …

then the tomcat container fails to connect to the database.

Notably, if I restart the docker daemon before restarting the containers then everything works fine. However, I am not too happy with this solution. First of all, I’d like to understand what is going on and secondly, a restart of the docker daemon affects all other running containers.

So I guess my questions are: Is there some residue of the link left when I stop the containers that the new tomcat container somehow tries to reuse? Or what else is going on? Am I doing something wrong? And is there a way to restart the containers without having to restart the docker daemon?

Thanks and best wishes,
Lutz