Hi there!
I’m encountering an issue where, when several networks (~ more than 4) are defined in docker-compose.yml
and attached to a service, at least one of them - seemingly random, and changing with every container recreation - doesn’t get attached to the container.
Steps to reproduce
docker network create -d bridge net1
docker network create -d bridge net2
docker network create -d bridge net3
docker network create -d bridge net4
docker network create -d bridge net5
mkdir /tmp/hello-world & cd /tmp/hello-world
vi docker-compose.yml && docker compose up
docker-compose.yml
version: '3'
networks:
net1:
external: true
net2:
external: true
net3:
external: true
net4:
external: true
net5:
external: true
services:
hello-world:
image: hello-world
container_name: hello-world
networks:
- net1
- net2
- net3
- net4
- net5
Issue
docker inspect hello-world
output
"Networks": {
"net1": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"hello-world",
"hello-world",
"762e6a7d7f6c"
],
"NetworkID": "4a5035ca7c5b15fd6eaddb5945965237f49e53b6c3deca3c4f12f1000d86442a",
"EndpointID": "",
"Gateway": "",
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "",
"DriverOpts": null
},
"net2": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"hello-world",
"hello-world",
"762e6a7d7f6c"
],
"NetworkID": "122b087c72835d2827f6d4d51cee2408f63be1769431ac7f6323afcdf15a2fc6",
"EndpointID": "",
"Gateway": "",
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "",
"DriverOpts": null
},
"net4": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"hello-world",
"hello-world",
"762e6a7d7f6c"
],
"NetworkID": "d9b683093c92c60d955c1d4f50c6968134577fec6f5fc97302ecb2bfea3e0e54",
"EndpointID": "",
"Gateway": "",
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "",
"DriverOpts": null
},
"net5": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"hello-world",
"hello-world",
"762e6a7d7f6c"
],
"NetworkID": "519df1ff81b1ab9415f9e2832038f09f74fcbd6fa200d9bd1db9971ab42862a7",
"EndpointID": "",
"Gateway": "",
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "",
"DriverOpts": null
}
}
You can notice that net3
is missing … When I recreate with docker compose up --force-recreate
it’s very likely that one of the other networks won’t be attached, but net3
will. When you recreate it often enough, sometimes even two won’t be attached; only rarely all networks will be attached as expected.
I didn’t have this issue before with only 2/3 networks attached to it, but I can’t imagine docker compose
can’t reliably handle 5 networks(?)…
This issue occurs on Debian as well as Fedora, every time with the latest packages from docker repository.
Any ideas what could cause this behaviour?