Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accidentally deleted docker networks, now containers won't start

I had a persistent state in a MySQL container I wanted to get rid of. Being a noob, I found a command which should do this for me - docker-compose down -v

I figured that if I change the YAML compose file so that it contains only the container whose state I want to delete, start it and then disable it using the command above, it will not touch other containers in any way. So that's what I did, I started only the one container, ran the command and after restarting it, the state was indeed gone. So far so good.

However, when I try to start the original bunch of containers, this is what happens:

ERROR: for mongo  Cannot start service mongo: network 9d1660acaba98e16fb130dd38b48a3ef0dedfd7a291b4ad6f7c7f280d72a86a4 not found

I do not understand what happened there. What is the right way to fix it?

like image 558
JohnEye Avatar asked Dec 23 '22 06:12

JohnEye


1 Answers

I was able to fix it using the following command. I have no idea whether it was the right thing to do, so be careful when applying it.

docker network create 9d1660acaba98e16fb130dd38b48a3ef0dedfd7a291b4ad6f7c7f280d72a86a4

Edit: It worked only once. Now I get the following error:

endpoint with name [name] already exists in network 9d1660acaba98e16fb130dd38b48a3ef0dedfd7a291b4ad6f7c7f280d72a86a4

Edit 2: The reason it worked only once was that I forgot to stop the network before trying to start it again.

like image 195
JohnEye Avatar answered Dec 28 '22 11:12

JohnEye