docker-composeで起動されたDockerコンテナがあります。構成ファイルは、2つのネットワークの一部でなければならないことを指定します。ただし、(5回実行中に約1回)コンテナはネットワークの1つのメンバーになります(つまり、コンテナはdocker network inspect <network_id>
表示されません)。これは私のMREです:
ドッカーファイル
FROM alpine:latest
ENTRYPOINT ["sleep", "infinity"]
docker-compose.yaml
version: "3.7"
services:
foo:
image: foo
init: true
networks:
- network1
- network2
networks:
network1:
network2:
docker network inspect foo_network2
プログラム
[
{
"Name": "foo_network2",
"Id": "2ef317904b46eddc3dcd8242f1ee41eff02756e016c701c2f2366bbbb166670e",
"Created": "2024-03-12T04:15:24.57501242Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "192.168.144.0/20",
"Gateway": "192.168.144.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {},
"Options": {},
"Labels": {
"com.docker.compose.network": "network2",
"com.docker.compose.project": "foo",
"com.docker.compose.version": "2.24.6"
}
}
]
そしてdocker network inspect foo_network1
見せて
[
{
"Name": "foo_network1",
"Id": "a505fd52cd34c9ecdad1aa27058cc7cb47243d82283a7c7949b211be422a10e8",
"Created": "2024-03-12T04:15:24.535686504Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "192.168.128.0/20",
"Gateway": "192.168.128.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"823f84eff688b9bc8e207b208cfb23852a2bc777b121107ab9d0ee48248e0b1d": {
"Name": "foo-foo-1",
"EndpointID": "37606efb0ea637c686edac7ccebab033dfd36f0cce9599d162a540a81d687b2f",
"MacAddress": "02:42:c0:a8:80:02",
"IPv4Address": "192.168.128.2/20",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {
"com.docker.compose.network": "network1",
"com.docker.compose.project": "foo",
"com.docker.compose.version": "2.24.6"
}
}
]
私はMac(エンジン25.0.3、Compose:2.24.6)でDocker Desktop 4.28.0を実行しています。 Ubuntu 23.10(エンジン25.0.2、docker-compose 1.29.2)ではこの動作を再現できません。