You try to start a container and Docker complains:
Error response from daemon: network mynetwork not found
The container is referencing a network that doesn’t exist on the Docker host.
What causes this
Docker containers can be attached to user-defined networks for inter-container communication. When you reference a network by name — either in a docker run command or a docker-compose.yml — Docker looks it up by that exact name. If it doesn’t exist, you get this error.
Common causes:
- You’re running a container that expects a network created by another Compose project
- The network was manually deleted or cleaned up with
docker system prune - There’s a typo in the network name
- You ran
docker compose downwhich removes project networks, then tried to start a standalone container that depended on one - You’re on a different machine or Docker context where the network was never created
Fix 1: Create the network manually
If you know the network name, just create it:
docker network create mynetwork
Then run your container:
docker run --network mynetwork my-image
You can specify the driver if needed (default is bridge):
docker network create --driver bridge mynetwork
Fix 2: List existing networks to find the right name
Maybe the network exists but with a different name. Docker Compose prefixes network names with the project name:
docker network ls
Output might look like:
NETWORK ID NAME DRIVER
abc123 bridge bridge
def456 myproject_mynet bridge
If you see myproject_mynet instead of mynet, use the full name or set an explicit name in your Compose file.
Fix 3: Define the network in Docker Compose
When using Docker Compose, networks are auto-created when you run docker compose up. Define them explicitly:
services:
web:
image: nginx
networks:
- mynet
api:
image: node:18
networks:
- mynet
networks:
mynet:
driver: bridge
If you need the network to have a specific name (without the project prefix), set it explicitly:
networks:
mynet:
name: mynetwork
driver: bridge
Fix 4: Use an external network
If multiple Compose projects need to share a network, declare it as external:
networks:
shared:
external: true
name: mynetwork
This tells Compose “don’t create this network — it already exists.” You must create it manually first with docker network create mynetwork.
Fix 5: Clean up and recreate
If things are in a messy state, tear everything down and start fresh:
docker compose down
docker network prune
docker compose up -d
The network prune command removes all unused networks. Then docker compose up recreates the ones defined in your Compose file.
Related resources
How to prevent it
- Use Docker Compose to manage networks — it handles creation and cleanup automatically
- If you share networks across projects, use
external: trueand document the setup step - Be careful with
docker system prune— it removes unused networks along with everything else - Use explicit
namefields in Compose network definitions to avoid confusion with auto-prefixed names