Skip to content

[BUG] Ignored mac_address field #10796

@davidedellagiustina

Description

@davidedellagiustina

Description

I have a macvlan network and a Docker container (deployed through compose) connected to it. I recently updated to compose V2, and since then the mac_address property of my container does not get applied anymore (it used to work fine before).

Compose file:

version: '3.7'

services:
  blocky:
    container_name: blocky
    hostname: blocky
    restart: unless-stopped
    image: spx01/blocky:latest
    mac_address: 2c:4d:54:00:00:01 # MAC address specified here
    networks:
      macvlan:
        ipv4_address: ${BLOCKY_IP} # Env variable properly instantiated
    volumes:
      - ./config/config.yml:/app/config.yml:ro
      - /certificates/blocky/:/certs:ro
    environment:
      TZ: 'Europe/Rome'

networks:
  macvlan:
    external: true

Output of docker inspect blocky (only relevant parts):

[
    {
        "Config": {
            "MacAddress": "2c:4d:54:00:00:01" // Apparently it gets correctly parsed from the compose file
        },
        "NetworkSettings": {
            "MacAddress": "", // But then it does not get set
            "Networks": {
                "macvlan": {
                    "IPAMConfig": {
                        "IPv4Address": "192.168.1.224"
                    },
                    "Gateway": "192.168.0.1",
                    "IPAddress": "192.168.1.224",
                    "IPPrefixLen": 22,
                    "MacAddress": "02:42:c0:a8:01:e0" // And a random one is assigned
                }
            }
        }
    }
]

Output of docker inspect macvlan (only relevant parts):

[
    {
        "Name": "macvlan",
        "Scope": "local",
        "Driver": "macvlan",
        "Containers": {
            "23368919c7ccd73f64f02d7db560c256fd74c528c70e721b72f1d8e8660a384b": {
                "Name": "blocky",
                "EndpointID": "e5dc69402099d43938deafef3172a288abfe26cd2f31702595600f2d2252a8a8",
                "MacAddress": "02:42:c0:a8:01:e0", // Cusom MAC address is not applied
                "IPv4Address": "192.168.1.224/22" // (Even though IP is)
            }
        },
        "Options": {
            "macvlan_mode": "bridge",
            "parent": "enp0s31f6"
        }
    }
]

Docker version

Client: Docker Engine - Community
 Version:           24.0.4
 API version:       1.43
 Go version:        go1.20.5
 Git commit:        3713ee1
 Built:             Fri Jul  7 14:50:55 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          24.0.4
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.5
  Git commit:       4ffc614
  Built:            Fri Jul  7 14:50:55 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.21
  GitCommit:        3dce8eb055cbb6872793272b4f20ed16117344f8
 runc:
  Version:          1.1.7
  GitCommit:        v1.1.7-0-g860f061
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Docker compose version

Docker Compose version v2.19.1

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions