When attaching a container to a network, the provided MacAddress is always ignored
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 72.1k
- Forks
- 19.2k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 164
Description
Description
When using the /v1.44/networks/{id}/connect endpoint (https://docs.docker.com/engine/api/v1.44/#tag/Network/operation/NetworkConnect) to connect a container to a network, the MacAddress field seems to be always ignored. When instead providing the same network configuration on creating a container, the MacAddress field is used.
Reproduce
- Use https://docs.docker.com/engine/api/v1.44/#tag/Container/operation/ContainerCreate to create a container
- Use https://docs.docker.com/engine/api/v1.44/#tag/Network/operation/NetworkConnect to attach the container to a network, providing a
MacAddress(in the simplest case, without any other config)
This unfortunately cannot be done with the CLI tool since docker network connect does not allow to specify the MAC address. (Which might explain why this wasn't noticed before.)
Expected behavior
Container uses the specified MAC address in the container.
docker version
Client:
Version: 27.0.3
API version: 1.46
Go version: go1.22.4
Git commit: 7d4bcd863a
Built: Mon Jul 1 21:15:54 2024
OS/Arch: linux/amd64
Context: default
Server:
Engine:
Version: 27.0.3
API version: 1.46 (minimum version 1.24)
Go version: go1.22.4
Git commit: 662f78c0b1
Built: Mon Jul 1 21:15:54 2024
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.7.19
GitCommit: 2bf793ef6dc9a18e00cb12efb64355c2c9d5eb41.m
runc:
Version: 1.1.13
GitCommit:
docker-init:
Version: 0.19.0
GitCommit: de40ad0
(also happens with other versions)
docker info
Client:
Version: 27.0.3
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: 0.15.1
Path: /usr/lib/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: 2.29.0
Path: /usr/lib/docker/cli-plugins/docker-compose
Server:
Containers: 3
Running: 1
Paused: 0
Stopped: 2
Images: 13
Server Version: 27.0.3
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: true
Native Overlay Diff: false
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 splunk syslog
Swarm: inactive
Runtimes: runc io.containerd.runc.v2
Default Runtime: runc
Init Binary: docker-init
containerd version: 2bf793ef6dc9a18e00cb12efb64355c2c9d5eb41.m
runc version:
init version: de40ad0
Security Options:
seccomp
Profile: builtin
cgroupns
Kernel Version: 6.9.9-arch1-1
Operating System: Arch Linux
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 15.52GiB
Name: xxx
ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Docker Root Dir: /var/lib/docker
Debug Mode: false
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Additional Info
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the /v1.44/networks/{id}/connect endpoint and compare its handling of MacAddress with the ContainerCreate endpoint. Reproduce the report using the API, then verify that connecting a container with a supplied MacAddress results in that address being used.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, go
- Domain
- api, networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100