Today I learned: Docker Compose networks
Key takeaway: Name shared Compose networks explicitly with the name key so a version upgrade cannot rename them.
Docker Compose 1.21.0 stopped stripping dashes from project names. If one service joins another’s network by name, that name just changed.
I have two sibling services, foo-service and bar-service, each with its own docker-compose.yml. bar-service joined foo-service’s default network like this:
# bar-service/docker-compose.yml
networks:
default:
external:
name: fooservice_default
Then it stopped connecting. The 1.21.0 changelog says: “Dashes and underscores in project names are no longer stripped out.” The network is now foo-service_default.
You can update the external name to foo-service_default. Or, as of Compose file format 3.5, set the network name yourself so it doesn’t depend on the directory name:
# foo-service/docker-compose.yml
version: "3.5"
networks:
default:
name: fooservice
With that in place, the original bar-service config works again.