-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Description
Bug Report
Summary
Docker Compose 5.1.0 broke multi-network stacks on Docker daemons older than API 1.44 (Docker Engine < 23.0), including Synology DSM 7.1 (API 1.41) and DSM 7.2 (API 1.43).
I maintain Dockhand, a Docker management application. Many of our users run Dockhand on Synology NAS devices (DSM 7.1/7.2), which ship with Docker 20.10 (API 1.41). This regression broke multi-network stack deployments for all of them when we updated docker-compose to 5.1.0. We had to cap docker-compose at 5.0.2 as a workaround while investigating the root cause.
Error Message
Container cannot be connected to network endpoints
This error comes from the Docker daemon when ContainerCreate receives multiple EndpointsConfig entries, which old daemons do not support.
Root Cause
Two changes in 5.1.0 combined to remove backward compatibility:
1. defaultNetworkSettings() refactor (commit fefdc9522)
In 5.0.2, extra networks were only added to EndpointsConfig for API >= 1.44:
// 5.0.2 — guarded by version check
if versions.GreaterThanOrEqualTo(version, APIVersion144) {
for _, networkKey := range serviceNetworks {
endpointsConfig[mobyNetworkName] = epSettings
}
}In 5.1.0, the guard was removed. Now ALL networks are unconditionally added to EndpointsConfig in ContainerCreate, even on old daemons:
// 5.1.0 — no guard, always adds all networks
for _, networkKey := range serviceNetworks {
endpointsConfig[mobyNetworkName] = epSettings
}2. The post-connect fallback was removed from convergence.go
In 5.0.2, createMobyContainer() had a fallback that connected extra networks one-by-one via NetworkConnect() for daemons older than API 1.44:
// 5.0.2 convergence.go — this was removed in 5.1.0
if versions.LessThan(apiVersion, APIVersion144) {
for _, networkKey := range serviceNetworks {
// skip primary (already in ContainerCreate)
// NetworkConnect() for each extra network
}
}Affected Users
- Synology DSM 7.1 (Docker API 1.41 / Engine 20.10)
- Synology DSM 7.2 (Docker API 1.43 / Engine 23.0-pre)
- Any Docker Engine < 23.0 (API < 1.44)
Reproduction
# docker-compose.yml
services:
web:
image: nginx:alpine
networks:
- frontend
- backend
networks:
frontend:
backend:Run docker compose up -d against a Docker 20.10 daemon:
Error response from daemon: Container cannot be connected to network endpoints
Expected Behavior
Same behavior as 5.0.2: multi-network stacks work on all supported Docker daemon versions.
Fix
Restore the two behaviors that existed in 5.0.2:
- In
defaultNetworkSettings()(create.go): only include extra networks inEndpointsConfigwhenapiVersion >= 1.44 - In
createMobyContainer()(convergence.go): add back the post-connect fallback that callsNetworkConnect()for each extra network whenapiVersion < 1.44
A fix is proposed in the linked PR.
Workaround
Downgrade to Docker Compose 5.0.2 or earlier.