Repository navigation
[BUG] Ifname label in driver-opt doesn't work #12740
Copy link
Copy link
Closed
Labels
Description
Description
Since release 28.0.0 we can add a new netlabel com.docker.network.endpoint.ifname to customize the interface name used when connecting a container to a network.
When added in a docker compose file, this network driver option is not applied, resulting in a container without the expected custom network interface name.
Steps To Reproduce
1. Environment
docker version
Client: Docker Engine - Community
Version: 28.0.4
API version: 1.48
Go version: go1.23.7
Git commit: b8034c0
Built: Tue Mar 25 15:07:11 2025
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 28.0.4
API version: 1.48 (minimum version 1.24)
Go version: go1.23.7
Git commit: 6430e49
Built: Tue Mar 25 15:07:11 2025
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.7.22
GitCommit: 7f7fdf5fed64eb6a7caf99b3e12efcf9d60e311c
runc:
Version: 1.1.14
GitCommit: v1.1.14-0-g2c9f560
docker-init:
Version: 0.19.0
GitCommit: de40ad0
2. Configuration
This is an example docker compose file:
services:
alpine:
image: alpine
command: sleep 100
networks:
net0:
networks:
net0:
ipam:
driver: default
config:
- subnet: 192.168.90.0/24
driver_opts:
com.docker.network.endpoint.ifname: net0
3. Command
docker compose up -d
4. Result/Error
docker exec -it docker-netlabel-alpine-1 sh
/ # ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
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
2: eth0@if661: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue state UP
link/ether 6a:ab:c8:45:23:9e brd ff:ff:ff:ff:ff:ff
inet 192.168.90.2/24 brd 192.168.90.255 scope global eth0
valid_lft forever preferred_lft forever
/ #
The interface name is supposed to be net0 but the actual name is still eth0
Compose Version
Docker Compose version v2.34.0
Docker Environment
Client: Docker Engine - Community
Version: 28.0.4
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.17.1
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.34.0
Path: /usr/libexec/docker/cli-plugins/docker-compose
scout: Docker Scout (Docker Inc.)
Version: v1.12.0
Path: /home/ab/.docker/cli-plugins/docker-scout
Server:
Containers: 2
Running: 1
Paused: 0
Stopped: 1
Images: 97
Server Version: 28.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 splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 7f7fdf5fed64eb6a7caf99b3e12efcf9d60e311c
runc version: v1.1.14-0-g2c9f560
init version: de40ad0
Security Options:
apparmor
seccomp
Profile: builtin
cgroupns
Kernel Version: 6.8.0-57-generic
Operating System: Ubuntu 22.04.5 LTS
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 62.68GiB
Name: zb
ID: 1981e7de-7493-4ebe-9805-c5edd353c5b6
Docker Root Dir: /var/lib/docker
Debug Mode: false
Experimental: false
Insecure Registries:
::1/128
127.0.0.0/8
Live Restore Enabled: false
Reactions are currently unavailable
Activity
atul2501 commentedon Apr 14, 2025
Hi,I just wanted to say that I’m also having this problem. When I add com.docker.network.endpoint.ifname in the driver_opts part of my Docker Compose file, it doesn’t work. I thought it would work because Docker Engine 28.0 supports it.
I was trying to set a custom network name inside the container, but Docker still uses the default name.
It would be really helpful if this could be fixed, or if someone can share a way to make it work. Thanks!
DVDAndroid commentedon Apr 14, 2025
Same problem here,
but running
docker network inspect mynetworkgives correctlycan someone confirm?
ndeloof commentedon Apr 22, 2025
this label must be set to endpoint setting, as container get connected to network, not as a network creation label:
ndeloof commentedon Apr 22, 2025
For usability I wonder we should introduce
ifname(orinterface?) as a service.networks attribute, wdyt @akerouanton ?akerouanton commentedon Apr 23, 2025
@ndeloof Agree 💯 Netlabels / raw driver options don't offer a nice UX.