Skip to content

[BUG] MAC address changed with the update #12364

@LordMilutin

Description

@LordMilutin

Description

Hello.
I have a docker-compose file that has fixed MAC address.
Everything worked flawlessly until recently which I suspect is the new docker update.

Now, when I redeploy the container (docker-compose down && docker-compose up), my fixed MAC address is changed.

I can still see the old one in one part of docker inspect command, but under Networks, it is another one. This used to be the fixed address, however that is not the case anymore.

Is there anything that can be done to preserve that fixed address again under Network, since our licences are based on MAC addresses.

My docker-compse:

services:
  serx:
    image: registry.my.ap/app:release
    container_name: serx
    restart: always
    ports:
      - "9090:9090"
    deploy:
      resources:
        limits:
          memory: 4G
    mac_address: 00:e0:84:35:d0:e8

Running docker inspect serx outputs this, and you can clearly see two MacAddress values, one that I set and one that is randomly generated:

[
    {
        "Id": "1d320278517429b8380ab19522908c3f6d8f0752658c26dca7802128cf028277",
        "Created": "2024-12-10T08:05:14.097145494Z",
        "Path": "/bin/sh",
        "Args": [
            "-c",
            "/bin/bash \"/home/serx/server/serx.sh\" \"console\""
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 31982,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2024-12-10T08:10:50.905014863Z",
            "FinishedAt": "2024-12-10T08:09:50.818190984Z"
        },
        "Image": "sha256:e37110e899db5af9c6edea669262f2e9d4a5914fb51edf59b6b19bd5b1b604f3",
        "ResolvConfPath": "/var/lib/docker/containers/1d320278517429b8380ab19522908c3f6d8f0752658c26dca7802128cf028277/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/1d320278517429b8380ab19522908c3f6d8f0752658c26dca7802128cf028277/hostname",
        "HostsPath": "/var/lib/docker/containers/1d320278517429b8380ab19522908c3f6d8f0752658c26dca7802128cf028277/hosts",
        "LogPath": "/var/lib/docker/containers/1d320278517429b8380ab19522908c3f6d8f0752658c26dca7802128cf028277/1d320278517429b8380ab19522908c3f6d8f0752658c26dca7802128cf028277-json.log",
        "Name": "/serx",
        "RestartCount": 13,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "docker-default",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [
            ],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "serx_default",
            "PortBindings": {
                "9090/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "9090"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "always",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": [],
            "ConsoleSize": [
                0,
                0
            ],
            "CapAdd": null,
            "CapDrop": null,
            "CgroupnsMode": "private",
            "Dns": null,
            "DnsOptions": null,
            "DnsSearch": null,
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "private",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 4294967296,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": null,
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": null,
            "DeviceCgroupRules": null,
            "DeviceRequests": null,
            "MemoryReservation": 0,
            "MemorySwap": 8589934592,
            "MemorySwappiness": null,
            "OomKillDisable": null,
            "PidsLimit": null,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": [
                "/proc/asound",
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware",
                "/sys/devices/virtual/powercap"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/a67da13cde679880b990f2deb56f30ff9038f2099590746dc04afcaa0ac6a9eb-init/diff:/var/lib/docker/overlay2/624193eb166fbff77e97cbd849e9cce79c0d2f2846278fbbf343662fb2642c83/diff:/var/lib/docker/overlay2/319a45e18aa9c2185647a6d86baa74617067b251c27b78e2a89352a53eef3abe/diff:/var/lib/docker/overlay2/295f17780f150f76854b257cd4dad1a559fb5bc35ac27fb3636c0e16af4a0786/diff:/var/lib/docker/overlay2/5f2e6229982d0b8456b96137d3f43fd128538742b9a46f6a73aefdeb5ef20a32/diff:/var/lib/docker/overlay2/2c9ac82f4dfdb4db5849e3688abd3dda402bedd456bf14e6fde9b2e197c1cace/diff:/var/lib/docker/overlay2/f658c1357cdacba6be91e42382a988017751f5af8c0048488d7f90b220351a8d/diff:/var/lib/docker/overlay2/d2d62120e34144a9d9bc9b4a57da9e83ca92b4306db00bcfdb0bf2f681062ab5/diff:/var/lib/docker/overlay2/7f888671e949b152a47fe4dbf8df62b26d559258c6636e19d2305022595767cd/diff:/var/lib/docker/overlay2/51b10a24c15b8f51e76c7a06d6831152d8f44f393266a119fb9dae6672c11ef9/diff:/var/lib/docker/overlay2/cc008842f62bc93f10e9e550a130322d9f1095308727f8a172cb39d72e691d24/diff:/var/lib/docker/overlay2/f32641471c9efb5e46ef9ce99c4e84e9b5036545a55b208ca90a2e8a1f550833/diff:/var/lib/docker/overlay2/f6c8527ffaeee8afa64fb19bfdcad89118dd0834f9db542cd45057c64bb59eaa/diff:/var/lib/docker/overlay2/1d9d41b2447776c9f7253024a25512c08bb94ed09febdcf4f34f7a74745b69b8/diff:/var/lib/docker/overlay2/65a80346cf492c0acf88e95da5260d8b4763520c6a83a721fb008f16b4121173/diff",
                "MergedDir": "/var/lib/docker/overlay2/a67da13cde679880b990f2deb56f30ff9038f2099590746dc04afcaa0ac6a9eb/merged",
                "UpperDir": "/var/lib/docker/overlay2/a67da13cde679880b990f2deb56f30ff9038f2099590746dc04afcaa0ac6a9eb/diff",
                "WorkDir": "/var/lib/docker/overlay2/a67da13cde679880b990f2deb56f30ff9038f2099590746dc04afcaa0ac6a9eb/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [
        ],
        "Config": {
            "Hostname": "1d3202785174",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "9090/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/openjdk-8/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "JAVA_HOME=/usr/local/openjdk-8",
                "LANG=C.UTF-8",
                "JAVA_VERSION=8u342"
            ],
            "Cmd": null,
            "Image": "image: registry.my.ap/app:release",
            "Volumes": {
                "/home/serx/server/conf/server.conf": {},
                "/home/serx/server/import": {},
                "/home/serx/server/licence": {},
                "/home/serx/server/logs": {},
                "/home/serx/server/uploads": {}
            },
            "WorkingDir": "",
            "Entrypoint": [
                "/bin/sh",
                "-c",
                "/bin/bash \"/home/serx/server/serx.sh\" \"console\""
            ],
            "MacAddress": "00:68:eb:af:61:a8",
            "OnBuild": null,
            "Labels": {
                "com.docker.compose.config-hash": "5b286e1f87200ce057aa63967b376b2ee9877774bea9da13b56fc30308d0593c",
                "com.docker.compose.container-number": "1",
                "com.docker.compose.oneoff": "False",
                "com.docker.compose.project": "serx",
                "com.docker.compose.project.config_files": "docker-compose.yml",
                "com.docker.compose.project.working_dir": "/home/demo/docker/serx",
                "com.docker.compose.service": "serx",
                "com.docker.compose.version": "1.29.2",
                "key": "LexCorp"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "a2ef26b56d2fdfac1350427426b4153a9d4173572f19f0f697ed7dd32b792f12",
            "SandboxKey": "/var/run/docker/netns/a2ef26b56d2f",
            "Ports": {
                "3030/tcp": null,
                "3032/tcp": null,
                "3306/tcp": null,
                "37777/tcp": null,
                "4070/tcp": null,
                "80/tcp": null,
                "9090/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "9090"
                    },
                    {
                        "HostIp": "::",
                        "HostPort": "9090"
                    }
                ]
            },
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "serx_default": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": [
                        "serx",
                        "1d3202785174"
                    ],
                    "MacAddress": "02:42:ac:15:00:02",
                    "NetworkID": "6d89dc6f827506748cd431b438395d1e165b5fad60576f15936e8fce9728741d",
                    "EndpointID": "a00e7716527639996a3a62245feb2dd5b1216b6e41aeea4494f800c213b3d70b",
                    "Gateway": "172.21.0.1",
                    "IPAddress": "172.21.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "DriverOpts": null,
                    "DNSNames": [
                        "serx",
                        "1d3202785174"
                    ]
                }
            }
        }
    }
]

Steps To Reproduce

No response

Compose Version


Docker Environment


Anything else?

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions