Libnetwork: iprange and aux_addresses is not work

Created on 14 Nov 2016  路  3Comments  路  Source: moby/libnetwork

Description

Steps to reproduce the issue:

  1. create docker network, set ipam settings iprange or aux_addresses
  2. start docker network
  3. start container using this network
  4. check your container address

Describe the results you received:

# cat docker-compose.yml 
version: '2'
services:
  nginx:
    image: nginx
    networks:
      - ipvlan111
    privileged: true
networks:
  ipvlan111:
    driver: ipvlan
    driver_opts:
      ipvlan_mode: l2
      parent: ens18.111
    ipam:
      driver: default
      config:
      - subnet: 192.168.111.0/24
        iprange: 192.168.111.192/29
        gateway: 192.168.111.1
        aux_addresses:
          nginx: 192.168.111.33
          test_nginx_1: 192.168.111.34

# docker-compose up -d
Creating network "test_ipvlan111" with driver "ipvlan"
Pulling nginx (nginx:latest)...
latest: Pulling from library/nginx
386a066cd84a: Pull complete
7bdb4b002d7f: Pull complete
49b006ddea70: Pull complete
Digest: sha256:9038d5645fa5fcca445d12e1b8979c87f46ca42cfb17beb1e5e093785991a639
Status: Downloaded newer image for nginx:latest
Creating test_nginx_1

# docker network inspect test_ipvlan111
[
    {
        "Name": "test_ipvlan111",
        "Id": "fd8a5c1300c83a1ac2f77a718f65d6eca1976aee983ec657398cfeb6e15f00e7",
        "Scope": "local",
        "Driver": "ipvlan",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "192.168.111.0/24",
                    "Gateway": "192.168.111.1",
                    "AuxiliaryAddresses": {
                        "nginx": "192.168.111.33",
                        "test_nginx_1": "192.168.111.34"
                    }
                }
            ]
        },
        "Internal": false,
        "Containers": {
            "685e6d4dc2ec9d38f230d916c28c5e797cfe67fe4e560a0407cfafdaddd60405": {
                "Name": "test_nginx_1",
                "EndpointID": "465eff2993d1dac7457cec4fb9b45546a5d2c4d93e492de8d6e7985c8d3b5817",
                "MacAddress": "",
                "IPv4Address": "192.168.111.2/24",
                "IPv6Address": ""
            }
        },
        "Options": {
            "ipvlan_mode": "l2",
            "parent": "ens18.111"
        },
        "Labels": {}
    }
]

# docker-compose exec nginx ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
63: eth0@if62: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default 
    link/ether 12:7c:7f:a1:8a:b4 brd ff:ff:ff:ff:ff:ff
    inet 192.168.111.2/24 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::107c:7fff:fea1:8ab4/64 scope link 
       valid_lft forever preferred_lft forever

Describe the results you expected:
As you can see the docker container is not got any of the declared addresses:

  • nginx: 192.168.111.33
  • test_nginx_1: 192.168.111.34

Also it is not got any address from the declared iprange:

  • 192.168.111.192/29

Output of docker version:

Client:
 Version:      1.12.3
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   6b644ec
 Built:        Wed Oct 26 22:07:18 2016
 OS/Arch:      linux/amd64
 Experimental: true

Server:
 Version:      1.12.3
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   6b644ec
 Built:        Wed Oct 26 22:07:18 2016
 OS/Arch:      linux/amd64
 Experimental: true

Output of docker info:

Containers: 2
 Running: 1
 Paused: 0
 Stopped: 1
Images: 3
Server Version: 1.12.3
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 9
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: null overlay host bridge ipvlan
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: apparmor seccomp
Kernel Version: 4.4.0-47-generic
Operating System: Ubuntu 16.04.1 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 11.73 GiB
Name: docker-host
ID: CGPQ:Y3VE:ND64:K4TG:R7SJ:GDOP:4LAK:OZI6:SO5E:7O57:VNMO:RGTD
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: No swap limit support
Experimental: true
Insecure Registries:
 127.0.0.0/8

Output of docker-compose version:

docker-compose version 1.8.1, build 878cff1
docker-py version: 1.10.3
CPython version: 2.7.9
OpenSSL version: OpenSSL 1.0.1e 11 Feb 2013

Most helpful comment

No problem. The docker user guide examples around aux-address have recently been improved, but I think we need to make this clearer, with an explicit statement around the meaning of that option.

All 3 comments

@kvaps
aux-address is to manually inform the ipam-driver about IP addresses already in use in the network, so that the driver will not give them out to containers. It is not a way for user to choose the container's address.
For that you need to use the --ip docker run option.

I am sorry, I didn't know.
Thank you for your clarification.

No problem. The docker user guide examples around aux-address have recently been improved, but I think we need to make this clearer, with an explicit statement around the meaning of that option.

Was this page helpful?
0 / 5 - 0 ratings