Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Gateway field in bridge network inspect #26799

Open
aboch opened this issue Sep 21, 2016 · 16 comments
Open

Missing Gateway field in bridge network inspect #26799

aboch opened this issue Sep 21, 2016 · 16 comments
Assignees
Labels
area/api area/networking kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. version/1.12

Comments

@aboch
Copy link
Contributor

aboch commented Sep 21, 2016

First time daemon is booted (no docker0 bridge present, no or empty /var/lib/docker/network/files/local-kv.db file), IPAM.Config structure in network inspect output will not contain the Gateway field

$ docker network inspect bridge
[
    {
        "Name": "bridge",
        "Id": "2b5cc5f97b6de6a5e0533b1e2d5bec6284d900a9a82632ce782320a19db8b9e0",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.17.0.0/16"
                }
            ]
        },

Verified problem exists in 1.11.2, 1.12.0 and in current master (1.13.0).

Given the IPAM.Config filed currently used to carry both configuration and operational data, the gateway address should always be there.

Note:
A daemon reload will fix the issue

@thaJeztah thaJeztah added area/api kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. area/networking version/1.12 labels Sep 21, 2016
@thaJeztah
Copy link
Member

We should check if this is a regression in 1.12, or already present in 1.11 (if not, possibly try to fix it for 1.12.2)

@aboch
Copy link
Contributor Author

aboch commented Sep 21, 2016

Issue is there in 1.11.2 as well, not a regression.
Given it won't be seen after a daemon reload, it might be the reason why it went unnoticed for so long.

@thaJeztah
Copy link
Member

Thanks for the extra info; not necessarily needed for 1.12.2 then

@bsushant-athena
Copy link

I'm not able to see gateway field in the user defined bridge network.

Docker version:

Docker version 17.03.1-ce, build c6d412e

Note: I'm using docker on mac machine.

@augi
Copy link

augi commented Sep 14, 2017

We have similar issue when using Docker Compose on TravisCI. It seems that the NetworkSettings part of docker inspect is not populated correctly - e.g. Ports and Networks.marathonvaultplugin_default.Gateways are empty (just sometimes!).

Full log: https://travis-ci.org/avast/marathon-vault-plugin/jobs/275438988#L720

@bwithem
Copy link

bwithem commented Oct 6, 2017

Seeing this on Docker version 1.13.0, build 49bf474 as well. We get the following error when trying to attach.

rpc error: code = 2 desc = containerd: container not found

A systemctl daemon-reload and stop/start of the docker daemon seem to get network working again and we can access containers.

@wansuyoo
Copy link

wansuyoo commented Dec 20, 2017

Are there any further additions?
We have same issue with Docker version 17.06.1-ce.
Under this conditions, container starting is failed.
As above cases, when docker deamon reloaded, it is fixed like as below.
And, container is ok, too.

[
    {
        "Name": "bridge",
        "Id": "50f6c311e204e5c2cdeec6852bc2900e171ffd4460a6d9ef5edb99430f8863c8",
        "Created": "2017-12-20T13:28:18.0498577Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.17.0.0/16",
                    "Gateway": "172.17.0.1"
                }
            ]
        },

@thaJeztah thaJeztah added this to Networking in maintainers-session Mar 22, 2018
@newnewcoder
Copy link

The same issue on Ubuntu 16.04 LTS with Docker version 18.06.1-ce, build e68fc7a.

It's fixed after run commands below:

sudo systemctl daemon-reload
sudo systemctl stop docker
sudo systemctl start docker

d-fence added a commit to odoo/runbot that referenced this issue Jan 10, 2019
When a build is running, the stmp is the localhost.
Since Docker builds, the localhost is the container which does not catch
port 25 smtp. Mails are lost in the limbo.

With this commit, the default gateway of the Docker network is used as
smtp host for the builds. It's the responsability of the runbot host to
catch smtp traffic from the container.

This bridge interface exists by default on a system where Docker is
running. However, Docker is affected by this issue:
moby/moby#26799

The first time the Docker daemon is installed, the Gateway is not
defined on the bridge interface. When the Docker daemon is restarted,
the gateway is correctly defined. Pay attention that restarting the
Docker daemon will kill all the running/testing builds.
d-fence added a commit to odoo/runbot that referenced this issue Jan 11, 2019
When a build is running, the stmp is the localhost.
Since Docker builds, the localhost is the container which does not catch
port 25 smtp. Mails are lost in the limbo.

With this commit, the default gateway of the Docker network is used as
smtp host for the builds. It's the responsability of the runbot host to
catch smtp traffic from the container.

This bridge interface exists by default on a system where Docker is
running. However, Docker is affected by this issue:
moby/moby#26799

The first time the Docker daemon is installed, the Gateway is not
defined on the bridge interface. When the Docker daemon is restarted,
the gateway is correctly defined. Pay attention that restarting the
Docker daemon will kill all the running/testing builds.
@lxdraw
Copy link

lxdraw commented Apr 16, 2020

I am seeing this same issue in Docker in Docker. TestContainers depends on their being a gateway defined, and can't route traffic correctly when it's missing. I have to relaunch the docker daemon before running my Testcontainer tests.

@flyinprogrammer
Copy link
Contributor

just started seeing this on amzn linux 2

@hank-scorpio
Copy link

This issue is still present in Docker 19.03.2 on Linux. Is there any way to solve this without restarting the service on first run?

@hommeabeil
Copy link

hommeabeil commented May 29, 2020

Getting this on Debian Buster,

docker version
Client: Docker Engine - Community
Version: 19.03.8
API version: 1.40
Go version: go1.12.17
Git commit: afacb8b7f0
Built: Wed Mar 11 01:25:56 2020
OS/Arch: linux/amd64
Experimental: false

Server: Docker Engine - Community
Engine:
Version: 19.03.8
API version: 1.40 (minimum version 1.12)
Go version: go1.12.17
Git commit: afacb8b7f0
Built: Wed Mar 11 01:24:28 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.2.13
GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683

After investiguig a little bit, its looks like everything is registered properly, I can look in the file /var/lib/docker/network/file/local-kv.db and I see a json with looks like the expected value from the docker network inspect. Are you just missing a lookup in the database ?

@avkonst
Copy link

avkonst commented Jul 8, 2020

I have seen this now with the latest docker. I am surprised it is nearly 4 years old issue.

@llitfkitfk
Copy link

have the same issue

Client: Docker Engine - Community
 Version:           20.10.7
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        f0df350
 Built:             Wed Jun  2 11:58:10 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.7
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       b0f5bc3
  Built:            Wed Jun  2 11:56:35 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.6
  GitCommit:        d71fcd7d8303cbf684402823e425e9dd2e99285d
 runc:
  Version:          1.0.0-rc95
  GitCommit:        b9ee9c6314599f1b4a7f497e1f1f856fe433d3b7
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
docker network inspect bridge
[
    {
        "Name": "bridge",
        "Id": "d0f87f91f1853bb16f82764665683529e27d831599a56e1e19302a6f06a615dc",
        "Created": "2021-07-10T23:22:35.604721866+08:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.80.0.0/24"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            
        },
        "Options": {
            "com.docker.network.bridge.default_bridge": "true",
            "com.docker.network.bridge.enable_icc": "true",
            "com.docker.network.bridge.enable_ip_masquerade": "true",
            "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
            "com.docker.network.bridge.name": "docker0",
            "com.docker.network.driver.mtu": "1500"
        },
        "Labels": {}
    }
]

yxieca added a commit to sonic-net/sonic-mgmt that referenced this issue Oct 7, 2021
What is the motivation for this PR?
There is a docker bridge network issue that would randomly cause "docker inspect bridge" to not show 'Gateway' IP.

Reference: moby/moby#26799

How did you do it?
We could use the 'Subnet' entry for the test purpose.

How did you verify/test it?
Run test against device exhibiting the docker bridge network issue.
119064273 pushed a commit to 119064273/sonic-mgmt that referenced this issue Jan 25, 2022
What is the motivation for this PR?
There is a docker bridge network issue that would randomly cause "docker inspect bridge" to not show 'Gateway' IP.

Reference: moby/moby#26799

How did you do it?
We could use the 'Subnet' entry for the test purpose.

How did you verify/test it?
Run test against device exhibiting the docker bridge network issue.
@ericslandry
Copy link

This comment might not be adding much, but I just wanted to contribute my reproducibility scenario.

Using docker-ce 20.10.14 and compose 2.3.3 on Ubuntu 20.04 and this compose.yaml :

services:
  hello:
    image: hello-world
    networks:
      - mgmt
networks:
  mgmt:
    enable_ipv6: true
    ipam:
      config:
        - subnet: "fddd:dead:beef::/64"
          gateway: "fddd:dead:beef::254"

I run docker compose up -d, and see this in the debug docker logs (note the missing Gateway) :

Apr 05 11:17:23 ===redacted=== dockerd[3300207]: time="2022-04-05T11:17:23.275880184-04:00" level=debug msg="form data: {\"Attachable\":false,\"CheckDuplicate\":false,\"ConfigFrom\":null,\"ConfigOnly\":false,\"Driver\":\"macvlan\",\"EnableIPv6\":true,\"IPAM\":{\"Config\":[{\"Subnet\":\"fddd:dead:beef::/64\"}],\"Driver\":\"\",\"Options\":null},\"Ingress\":false,\"Internal\":false,\"Labels\":{\"com.docker.compose.network\":\"mgmt\",\"com.docker.compose.project\":\"poc\",\"com.docker.compose.version\":\"2.3.3\"},\"Name\":\"poc_mgmt\",\"Options\":{\"parent\":\"ens4.4028\"},\"Scope\":\"\"}"

Then I look at the created Docker network (note the empty IPv6 Gateway)

$ docker network inspect poc_mgmt|jq .[].IPAM.Config
[
  {
    "Subnet": "172.18.0.0/16",
    "Gateway": "172.18.0.1"
  },
  {
    "Subnet": "fddd:dead:beef::/64"
  }
]

But after a sudo systemctl restart docker , the IPv6 Gateway is populated, but not with the IP I requested (fddd:dead:beef::254):

$ docker network inspect poc_mgmt|jq .[].IPAM.Config
[
  {
    "Subnet": "172.18.0.0/16",
    "Gateway": "172.18.0.1"
  },
  {
    "Subnet": "fddd:dead:beef::/64",
    "Gateway": "fddd:dead:beef::1"
  }
]

@schulze
Copy link

schulze commented Apr 25, 2022

I seems this was a bug in docker compose, that should now be fixed: docker/compose@41b3967

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api area/networking kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. version/1.12
Projects
maintainers-session
  
Networking
Development

No branches or pull requests