Software

docker-compose fails with 'no such network' after compose v2 upgrade; existing overlay network collisions on Ubuntu 22.04

Environment

Environment

Ubuntu 22.04 host running Docker Engine 24.0, several docker-compose (compose v2) project stacks and a pre-existing Docker Swarm overlay network named proj_default created earlier by a legacy script.

Symptoms

Symptoms

docker compose up for one project fails with: "ERROR: network proj_default declared as external, but could not be found" or "no such network: proj_default". Other unrelated containers keep running.

Observations

Observations

docker network ls shows two networks with the same human-readable name but different IDs and drivers (bridge vs overlay). docker daemon logs show repeated errors about creating endpoints and network driver 'overlay' refusing attach. docker-compose v2 CLI appears to be creating a local named network that collides with the external overlay.

Already attempted

Already attempted

Tried 'docker compose down' and 'docker compose up --remove-orphans', removed the named network with 'docker network rm' (one instance), restarted Docker, changed COMPOSE_PROJECT_NAME and project directory, tried 'docker network create --driver bridge proj_default' then re-run compose.

Question

Question

What caused the network name collision after upgrade and how can I safely restore compose stacks without impacting Swarm overlay networks or other running services?

COMMUNITY RESPONSES

Verified community troubleshooting

0 replies

No answers yet..

Showing 0 of 0 community responses
AI DIAGNOSTICS

Incident analysis

Updated 4w ago• Trouble ID

Most likely causes

Compose v2 changed network-scoping/namespace behavior and created a local bridge network with same human name as an existing overlay network 85%
An external script previously created an overlay network with the same name; compose tries to use it but driver mismatch causes errors 70%
Leftover network metadata from an earlier docker network rm left ambiguous entries and daemon cache needs restart 40%

Summary

After upgrading to compose v2 the CLI namespaces project networks differently and will create/expect local bridge networks named like _default unless explicitly declared external. That can collide with pre-existing overlay networks created earlier (same name). Docker Engine allows multiple networks to share the same user-facing name across drivers but compose treats missing external networks as an error. Attempts to remove networks can orphan running services that still depend on the overlay; simply recreating a bridge network with the same name may not resolve driver mismatches. The safe fix is to explicitly declare the intended network driver in compose files or rename external networks and rebind stacks, or recreate the external network with the correct driver after stopping dependent services.

Suggested Fixes

Diagnostic step 1
List networks and inspect both entries: docker network ls --no-trunc and docker network inspect <ID> to confirm driver (bridge vs overlay) and attached containers
Diagnostic step 2
Identify which running services depend on the overlay: docker ps --filter network=<network-name> or docker network inspect <overlay-ID>
Diagnostic step 3
Avoid force-removing an overlay while services use it; stop dependent services (docker service rm or stop containers) before network removal

Continue troubleshooting

Matched from the title, description and tags