Skip to content

Network gateway: Address already in use #8742

Description

@eirikb

Description

Trying to set a gateway to a specific address, but it won't be set.
If I try to set it to 10.10.1.100 the bridge adapter will still be set to 10.10.1.1.
This worked fine in v1, so unless the configuration have changed it could be a bug in v2.

Example:

services:
  A:
    image: nginx
    networks:
      mynet:
        ipv4_address: '10.10.1.1'
networks:
  mynet:
    ipam:
      config:
        - subnet: '10.10.1.0/24'
          gateway: '10.10.1.100'
eirikb@eh ~/d/t/test> docker network ls
NETWORK ID     NAME         DRIVER    SCOPE
a6cd841ba53a   bridge       bridge    local
4a5d7a11984c   host         host      local
66153911b158   none         null      local
d5c0ad6095d8   test_mynet   bridge    local
eirikb@eh ~/d/t/test> ip a | grep 10.10
    inet 10.10.1.1/24 brd 10.10.1.255 scope global br-d5c0ad6095d8
eirikb@eh ~/d/t/test> docker network inspect test_mynet
...
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "10.10.1.0/24"
                }
            ]
        },
...

Steps to reproduce the issue:

  1. Create a file docker-compose.yml with contents as described above
  2. Run docker-compose up

Describe the results you received:

eirikb@eh ~/d/t/test> docker-compose up
[+] Running 2/2
 ⠿ Network test_mynet  Created                                                                                                                                                                                 0.0s
 ⠿ Container test-A-1  Created                                                                                                                                                                                 0.5s
Attaching to test-A-1
Error response from daemon: Address already in use

Describe the results you expected:

No error

Output of docker compose version:

Docker Compose version 2.0.1

Additional environment details:

Tested on two different computers. Both running Arch Linux. Both Docker and Compose are from pacman.

Activity

  1. potiuk commented on Oct 4, 2021

    @potiuk

    We had to pin docker-compose to 1.29.2 in our CI due to this bug :(

  2. dereddy93 commented on Nov 2, 2021

    @dereddy93

    Running into the same issue here.

    Tried it on Ubuntu Linux and Docker Desktop for Mac (Version 4.1.1) - both compose files work like a charm if I use the python compose implementation. Also the version of the compose file does not seem to have an influence neither. Reproduced the "bug" on all of the available compose versions (from 3.8 down to 2.0).

    Edit: Updated to Docker Desktop for Mac Version 4.2.0 today. Bug is still present in this version.

  3. focardi commented on Nov 4, 2021

    @focardi

    Same issue here. Docker Desktop for Mac (version 4.1.1). Docker Compose version v2.0.0.

    I have gateway: 172.30.0.254 in the configuration file but it seems to ignore it and assigns IP 172.30.0.1 to the gateway which, by the way, was the static IP of one of the containers on the network and I get Error response from daemon: Address already in use.

    It worked with previous versions of compose.

  4. potiuk commented on Nov 4, 2021

    @potiuk

    I think that the best approach ais that you simply find what is listening on that port. Depending on the system there are ways to check it (can be easily googled). Can you post here what is listening on the port ? Is it another breeze started (breeze stop should help with it) or another process ? Can you let us both know?

  5. gaby commented on Feb 2, 2022

    @gaby

    I'm running into this issue just by using gateway: 10.8.1.1. No matter what we try it doesnt use the gateway we provide.

    We waited a few months before committing to migration to compose v2 and this bug essentially broke our whole infrastructure. Debating wether to just fork v1 and forget about v2 with the amount of bugs.

    When using 10.8.1.1 the container gets started with 10.8.0.0 as gateway. Our netmask is 255.255.0.0.

  6. gaby commented on Apr 4, 2022

    @gaby

    We still havent been able to upgrade to compose v2 becuase of this bug, still stuck with 1.29.2.

  7. gaby commented on Apr 4, 2022

    @gaby

    Similar #9330

  8. gaby commented on Apr 23, 2022

    @gaby

    Will this ever get fixed? We still stuck with 1.29.2 ...

  9. blop commented on Apr 23, 2022

    @blop

    @gaby Hopefully yes ;-) @qnap-ericfan has opened a pull request with a fix : #9363

  10. added a commit that references this issue on Oct 9, 2022
  11. stale commented on Oct 30, 2022

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

  12. gaby commented on Oct 30, 2022

    @gaby

    This issue was fixed via #9363

  13. stale commented on Oct 30, 2022

    @stale

    This issue has been automatically marked as not stale anymore due to the recent activity.

  14. stale commented on May 22, 2023

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

  15. ndeloof commented on May 22, 2023

    @ndeloof
    Contributor

    Tested with latest release v2.18.1:

    docker network inspect reports the expected gateway being set

    "IPAM": {
                "Driver": "default",
                "Options": null,
                "Config": [
                    {
                        "Subnet": "10.10.1.0/24",
                        "Gateway": "10.10.1.100"
                    }
                ]
            },

    issue indeed has been fixed by #9363, so closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions