Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

Docker says the network you named does not exist

ErrorError response from daemon: network myapp not found

Short answer

A container or Compose file refers to a network name the daemon does not have. List networks with docker network ls and compare the exact name. Then create the network yourself, correct the name in the file, or stop whatever deleted it. Compose never creates external networks.

  • Applies to Docker Engine 28, Docker Compose 2.3x
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    List the networks the daemon has and filter by the name in the error.

    docker network ls --filter name=myapp
  2. 2Match what you see, then jump to its fix

    1. 1The Compose file has external: true under the network, and the list shows nothingThe network is marked external and was never createdFix
    2. 2The list shows a similar name, such as a project prefix before the nameThe name is not what you think it isFix
    3. 3The error appears after docker compose down or after cleanup, for a container started with --networkcompose down removed the network a container still usesFix

What does the error look like?

  • Error response from daemon: network myapp not found

Cause 1 of 3

The network is marked external and was never created

1Check

With external: true, Compose does not create the network and returns an error if it does not exist.

grep -n -B2 -A2 'external' compose.yaml

2Fix

Create the network once with the exact name, then start the project.

docker network create myapp
docker compose up -d

3Verify

The network is listed and the containers are attached.

docker network ls --filter name=myapp

Confirmed by docs.docker.com

Did this fix it?

Cause 2 of 3

The name is not what you think it is

1Check

A network that Compose creates for you gets a project-scoped name, but a name set with the name attribute is used as is, with no project prefix.

docker network ls

2Fix

Use the full name from the list when you run containers by hand, or set the name attribute in the Compose file so both agree.

networks:
  default:
    name: myapp

3Verify

Start the project and look for the exact name.

docker compose up -d
docker network ls --filter name=myapp

Confirmed by docs.docker.com

Did this fix it?

Cause 3 of 3

compose down removed the network a container still uses

1Check

Compose down removes the networks defined in the file's networks section. External networks are never removed.

docker ps -a --format '{{.Names}}' | head

2Fix

Create the network again before starting containers by hand, or declare it as external in the file that owns the containers.

docker network create myapp
docker run -d --network myapp --name web nginx

3Verify

The container runs and is attached to the network.

docker network inspect myapp

Confirmed by docs.docker.com

Did this fix it?

How do I stop it coming back?

  • Create shared networks in a setup script or in one Compose file that owns them.
  • Use the name attribute so the real network name is explicit.
  • Before cleanup commands, list what each one removes.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.