120

When starting a docker container (not developed by me), docker says a network has not been found.

Does this mean the problem is within the container itself (so only the developer can fix it), or is it possible to change some network configuration to fix this?

8 Answers 8

177

I'm assuming you're using docker-compose and seeing this error. I'd recommend

docker-compose up --force-recreate <name>

That should recreate the containers as well as supporting services such as the network in question (it will likely create a new network).

7
  • 1
    Thanks. Indeed using docker-compose. Resetting Docker to factory settings worked... I will try your solution if it comes up again.
    – user118967
    Commented Dec 1, 2018 at 19:34
  • Super happy to help, it would be awesome if you'd accept the answer, that way other coming this way will have a clear signal that it worked :). More on accepting answers -> meta.stackexchange.com/questions/23138/… Commented Dec 1, 2018 at 21:14
  • 1
    Oh gotcha, well it might make sense to describe what you did in a bit more detail and accept that :) Commented Dec 3, 2018 at 9:34
  • 1
    Thanks for the suggestion. I was working on another project using docker-compose and had network issues. I forgot that I had run docker network prune which, of course, trashed all my docker networks!
    – dougB
    Commented Apr 12, 2020 at 5:59
  • 1
    I have a similar issue today, Once my host accidentally powered off immediatelly, the same error message came up when I try to start up the container. This answer brings my container up again. Thanks. This should be the accepted answer.
    – Bogie
    Commented Dec 17, 2021 at 11:01
121

shutdown properly first, then restart

docker-compose down
docker-compose up
2
  • I did messed up with "docker network prune", so I had to do this clean solution to have my stack up again. Thanks
    – thanos.a
    Commented Dec 16, 2020 at 10:52
  • This worked for me. I was bringing up the network via Docker Desktop's Dashboard. I brought things down via the command line and then up again and it works. Commented May 6, 2022 at 13:33
23

This can be caused by some old service that has not been killed, first add --remove-orphans flag when bringing down your container to remove any undead services running, then bring the container back up

docker-compose down --remove-orphans

docker-compose up
15

I was facing this similar issue and this worked for me :

Try running this - docker container ls -a and remove the container id by docker container rm ca877071ac10 (this is the container id ).

The problem was there were some old container instances which were not removed. Once all the old terminated instances get removed, you can start the container with docker-compose file

1
  • 1
    tried with rm didn't work, properly shutting down the docker-compose or force recreate helps
    – Shek
    Commented Apr 25, 2021 at 4:39
10

This is based in this answer.

In my case the steps that produced the error where:

  1. Server restart, containers from a docker-compose stack remained stopped.
  2. Network prune ran, so the network associated with stack containers where deleted.
  3. Running docker-compose --project-name "my-project" up -d failed with the error described in this topic.

Solved simply adding force-recreate, in this way:

docker-compose --project-name "my-project" up -d --force-recreate

This possibly works because with this containers are recreated linked with the also recreated network (previously pruned as described in the pre conditions).

1
  • first run... docker-compose down and after docker-compose up -d --force-recreate Commented Jul 19, 2021 at 17:23
6

Apparently VPN was causing this. Turning off VPN and resetting Docker to factory settings has solved the problem in two computers in our company. A third, personal computer that did not have VPN never showed the problem.

5

Amongst other things docker system prune will remove 'all networks not used by at least one container' allowing them to be recreated next docker-compose up

More precisely docker network prune can also be used.

0

Find the name of the network in the NetworkSettings/Networks section

docker inspect container_name

Create a new network

docker network create network_name

Connect the network to the container

docker network connect network_name container_name

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.