Skip to content

statically assigned ipv6 address only last(?) block into account #45402

@steiler

Description

@steiler

Description

It seems like any other then the last block in an ipv6 address is ignored when trying to assign static IPs.

Reproduce

# create a network with v6 enabled
mava@server01:~/projects/schema-server$ docker network create --ipv6 --subnet fd1a:b128::/32 mynet123
ebba0bf437a9d8f9ff4f1e245c3b09e65cbaa7c58ad235efd7bdd14bb91b0e38
# create first container
mava@server01:~/projects/schema-server$ docker run --name u1 -d --net mynet123 --ip6 fd1a:b128:5901::101 ubuntu sleep 999
ca4d0eaf28ba46a61cd75a17ff73b4679d2c2f3624e739dc4fca7a190763c6a7
# create second container
mava@server01:~/projects/schema-server$ docker run --name u2 -d --net mynet123 --ip6 fd1a:b128:5902::101 ubuntu sleep 999
50dbecfb20b881cddd9488839d464c7a10d63f72cb5a2261824e8db8db2f863c
docker: Error response from daemon: Address already in use.

Also after removing the u1 container and starting u2 alone the assigned address is incorrect

mava@server01:~/projects/schema-server$ docker run --name u2 -d --net mynet123 --ip6 fd1a:b128:5902::101 ubuntu sleep 999
b1690c53cde7cbbe154e84cfbb6e13d0a44eccdc1f0fb9d615ce6e50646189eb
mava@server01:~/projects/schema-server$ docker inspect u2 | jq ".[0].NetworkSettings.
Networks"
{
  "mynet123": {
    "IPAMConfig": {
      "IPv6Address": "fd1a:b128:5902::101"
    },
    "Links": null,
    "Aliases": [
      "b1690c53cde7"
    ],
    "NetworkID": "e55acf5bb5a72a755d791c7b6dcde060e7bba33c3ae7c352c5c48d63b40aa9f4",
    "EndpointID": "b908bdb736888b861e1458e46bc5301bd4c7e8cb3dba0af3d016883c7af201bb",
    "Gateway": "172.28.0.1",
    "IPAddress": "172.28.0.2",
    "IPPrefixLen": 16,
    "IPv6Gateway": "fd1a:b128::1",
    "GlobalIPv6Address": "fd1a:b128::101",
    "GlobalIPv6PrefixLen": 32,
    "MacAddress": "02:42:ac:1c:00:02",
    "DriverOpts": null
  }
}

Expected behavior

u1 should have ipv6 address fd1a:b128:5901::101 and u2 should have ipv6 address fd1a:b128:5902::101 assigned.

docker version

Client: Docker Engine - Community
 Version:           23.0.4
 API version:       1.42
 Go version:        go1.19.8
 Git commit:        f480fb1
 Built:             Fri Apr 14 10:32:03 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          23.0.4
  API version:      1.42 (minimum version 1.12)
  Go version:       go1.19.8
  Git commit:       cbce331
  Built:            Fri Apr 14 10:32:03 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.20
  GitCommit:        2806fc1057397dbaeefbea0e4e17bddfbd388f38
 runc:
  Version:          1.1.5
  GitCommit:        v1.1.5-0-gf19387a
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.10.4
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.17.2
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 32
  Running: 0
  Paused: 0
  Stopped: 32
 Images: 26
 Server Version: 23.0.4
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 2806fc1057397dbaeefbea0e4e17bddfbd388f38
 runc version: v1.1.5-0-gf19387a
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 5.15.0-70-generic
 Operating System: Ubuntu 22.04.2 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 16
 Total Memory: 62.7GiB
 Name: server01
 ID: 4d9b7b88-00a5-4658-9a37-a1d6f11f745d
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional Info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/networkingNetworkingarea/networking/ipv6Networkingkind/bugBugs are bugs. The cause may or may not be known at triage time so debugging may be needed.version/23.0

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions