The specified Docker network does not exist
This error appears when you try to attach a container to a Docker network that has not been created. It's a configuration error, often happening in multi-container setups or when scripts expect a certain network to be present.
- 1A typo in the network name specified with the '--network' flag.
- 2The script or 'docker-compose.yml' file refers to a network that should have been created manually but wasn't.
- 3In a docker-compose setup, you are trying to run a single service that depends on a network created by the full stack.
- 4The network was removed, but a command or script is still trying to use it.
A script attempts to run a container on a custom network named 'app-net' before creating it.
docker run -d --name my-app --network app-net my-app-image
expected output
docker: Error response from daemon: network app-net not found.
Fix 1
Create the Docker Network
WHEN The network is intended to exist and is needed for container communication.
# Create a new bridge network docker network create app-net
Why this works
This pre-creates the required network, making it available for containers to connect to.
Fix 2
Correct the Network Name
WHEN The error is caused by a typo.
# List available networks to find the correct name docker network ls # Use the correct network name docker run -d --name my-app --network my-app_default my-app-image
Why this works
Ensures the '--network' flag points to an existing network.
Fix 3
Use Docker Compose
WHEN Managing multiple containers that need to communicate.
# In docker-compose.yml
services:
app:
image: my-app-image
networks:
- app-net
networks:
app-net:
driver: bridge
# Run compose to create networks and containers automatically
docker-compose up -dWhy this works
Docker Compose automatically handles the creation and teardown of networks defined in the YAML file, preventing this error.
✕ Connect all containers to the default 'bridge' network and use IP addresses.
This is brittle and breaks Docker's built-in DNS-based service discovery. Custom networks provide network isolation and allow containers to communicate using their service names.
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev