This error occurs when Docker cannot find the network specified in your command or docker-compose file. The network may have been deleted, never created, or the name is misspelled. The fix involves recreating the network or updating your configuration.
The "network not found" error occurs when Docker tries to connect a container to a network that doesn't exist in the Docker daemon's registry. Docker maintains a list of networks, and when you reference a network by name or ID that isn't in this list, you get this error. This commonly happens when: - The network was manually deleted or pruned while containers still reference it - You're using docker-compose with an external network that was never created - A container was started with a specific network that no longer exists - Docker was restarted and some network metadata was lost (zombie networks) - The network name in your configuration has a typo or case mismatch Docker networks are case-sensitive, so "MyNetwork" and "mynetwork" are treated as different networks. Additionally, networks created by docker-compose typically follow the naming pattern `<project>_<network>` unless explicitly named.
First, verify whether the network actually exists:
docker network lsLook for the network name in the output. If you don't see it, the network needs to be created.
You can also search for a specific network:
docker network ls --filter name=<network_name>Note: Network names are case-sensitive. "myapp" and "MyApp" are different networks.
If the network doesn't exist, create it:
docker network create <network_name>For a specific driver (bridge is default):
docker network create --driver bridge <network_name>If using docker-compose with external networks, create the network before running docker-compose up:
docker network create my_external_network
docker-compose up -dIf you're using docker-compose with external networks, ensure the network exists or change your configuration.
Option 1: Create the external network first:
docker network create my_networkOption 2: Let docker-compose manage the network by removing the external declaration:
# Before (requires pre-existing network)
networks:
my_network:
external: true
# After (docker-compose creates the network)
networks:
my_network:
driver: bridgeOption 3: Use external with the correct name:
networks:
my_network:
external: true
name: actual_network_name # Must match exactlySometimes Docker shows a network in docker network ls but fails to remove or use it (zombie network). This typically happens after Docker crashes or is forcefully stopped.
Solution: Restart the Docker daemon:
# Linux
sudo systemctl restart docker
# macOS/Windows Docker Desktop
# Restart Docker Desktop from the menu bar/system trayAfter restart, the zombie network should be properly removed, and you can create a new one:
docker network create <network_name>If using docker-compose and the network state is inconsistent, force recreation:
docker-compose down --remove-orphans
docker-compose up --force-recreate -dFor a complete reset including volumes (warning: this deletes data):
docker-compose down --volumes --remove-orphans
docker network prune -f
docker-compose up -dOld containers may reference networks that no longer exist. Find and remove them:
# List all containers (including stopped)
docker container ls -a
# Remove old containers
docker container rm <container_id>
# Or remove all stopped containers
docker container pruneAfter removing orphaned containers, you can cleanly recreate your networks and start fresh.
Overlay networks in Swarm mode: Overlay networks are scoped to the swarm and can only be used with swarm services. If you try to use an overlay network with docker run on a single node, you'll get "network not found" because overlay networks aren't visible to standalone containers. Use docker service create --network <overlay_network> instead.
Network inspection for debugging: When troubleshooting, inspect the network configuration:
docker network inspect <network_name>This shows:
- Connected containers
- IPAM configuration (subnet, gateway)
- Network driver and options
- Labels and other metadata
Docker Compose project prefixing: Docker Compose prefixes network names with the project name (usually the directory name). A network defined as mynet in a project called webapp becomes webapp_mynet. Reference it correctly:
docker network ls --filter name=webapp_mynetAttachable networks: For overlay networks that need to work with both swarm services and standalone containers, create them with the attachable flag:
docker network create -d overlay --attachable my_overlayNetwork aliases: If containers need to reach each other by name, ensure they're on the same user-defined network. The default bridge network doesn't provide automatic DNS resolution between containers.
Cleaning up stale networks: Periodically clean unused networks:
docker network pruneThis removes all networks not used by at least one container. Use with caution in production as it may remove networks that stopped containers depend on.
dockerfile parse error line 5: unknown instruction: RRUN
How to fix 'unknown instruction' Dockerfile parse error in Docker
Error response from daemon: manifest for nginx:nonexistent not found: manifest unknown: manifest unknown
How to fix 'manifest for image:tag not found' in Docker
Error response from daemon: invalid reference format: repository name must be lowercase
How to fix 'repository name must be lowercase' in Docker
Error response from daemon: No such image
How to fix 'No such image' in Docker
Error response from daemon: Container is not running
How to fix 'Container is not running' when using docker exec