Got something weird with compose; containers are created, but docker inspect
does not show IP-address information of them. Very simple docker-compose.yml
;
version: 2
services:
server-a:
image: nginx
server-b:
image: nginx
After running docker-compose up -d
, containers are created, and attached to a network for the project, but a docker inspect does not show IP-address information;
"NetworkSettings": {
"Bridge": "",
"SandboxID": "207b243445d2600860d5280b81c9ecba9e088a75f6156d1df906b1a48ab33164",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"443/tcp": null,
"80/tcp": null
},
"SandboxKey": "/var/run/docker/netns/207b243445d2",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"testing_default": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"server-a"
],
"NetworkID": "",
"EndpointID": "",
"Gateway": "",
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": ""
}
}
}
Containers _are_ in fact having an IP-address assigned, and function correctly.
Not sure if this is a bug in docker-compose or engine
Since the containers function properly they must have an IP address, so i would guess this is an issue with engine.
Strangely, this doesn't happen with containers I create with docker run
:
$ docker network create test
d7f544661e865c981d1f518b81bc7bcad971131436d1e5cab2f81af52333e4cb
$ docker inspect --format='{{json .NetworkSettings.Networks}}' $(docker run --net=test -d busybox top)
{
"test": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "d7f544661e865c981d1f518b81bc7bcad971131436d1e5cab2f81af52333e4cb",
"EndpointID": "5fcd56efbf8aea99f8d5fbe7a50696c939c12f4ea306833a821c2073c9cfd265",
"Gateway": "172.18.0.1",
"IPAddress": "172.18.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:12:00:02"
}
}
@dnephin true, they actually have an IP-address
I have the same issue. I've worked around it by going through docker network inspect
, which correctly maps container ID to IP address.
This is an Engine bug, which is triggered when attempting to connect a container to a network it's already connected to. I've opened an issue here: https://github.com/docker/docker/issues/19669
It's actually closed on the Compose side by https://github.com/docker/compose/pull/2746, because that makes a change where we disconnect the container before reconnecting it.
Alarmingly, Compose doesn't error out even though the API returns an error on the /connect
request. That's a docker-py bug, which I'll fix.
docker-py now raises errors: https://github.com/docker/docker-py/pull/907
Between https://github.com/docker/compose/pull/2746, https://github.com/docker/docker-py/pull/907 and https://github.com/docker/docker/pull/19673 (which fixes the actual issue), I think we can call this one thoroughly fixed.
Facing this same issue using docker-compose version 1.24.0, build 0aa59064
on Docker Engine 18.09.6
:
Client: Docker Engine - Enterprise
Version: 18.09.6
API version: 1.39
Go version: go1.10.8
Git commit: 1578dcadd2
Built: 05/04/2019 02:34:11
OS/Arch: windows/amd64
Experimental: false
Server: Docker Engine - Enterprise
Engine:
Version: 18.09.6
API version: 1.39 (minimum version 1.24)
Go version: go1.10.8
Git commit: 1578dcadd2
Built: 05/04/2019 02:32:24
OS/Arch: windows/amd64
Experimental: false
docker inspect <container-id>
results in the following output (truncated):
NetworkSettings": {
"Bridge": "",
"IPAddress": "",
}
It's worth nothing that a bridged network has been added to the container however. Do we simply parse this instead for the time being? Or has a fix already been merged with master? In which case I need to update?
Thanks
Most helpful comment
I have the same issue. I've worked around it by going through
docker network inspect
, which correctly maps container ID to IP address.