portainer: mac_address is being ignored in docker-compose files

Before you start please confirm the following.

Problem Description

This is the docker-compose used for setting the mac_address line. This used to work fine until recently. If I run this outside of Portainer with docker-compose up it generates the MAC address fine.

I am not using a swarm, which another user was having an issue with the same problem: https://github.com/portainer/portainer/issues/9152

Does this have to do with the issue? https://github.com/moby/moby/pull/46406

# Wyoming-OpenWakeWord Container for Docker
version: "3.9"
services:
  wyomingopenwakeword:
    container_name: "wyoming-openwakeword"
    image: "rhasspy/wyoming-openwakeword:latest"
    labels:
      - "com.centurylinklabs.watchtower.enable=true"
      - "com.centurylinklabs.watchtower.monitor-only=false"
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /var/lib/libvirt/images/usb001/docker-storage/wyoming-openwakeword/data:/data
    mac_address: "9e:de:ad:be:ef:01"
    hostname: "wyomingopenwakeword"
    networks:
      - dhcp
    ports:
      - 10400:10400
    devices:
      - /dev/snd:/dev/snd
    command: --model 'ok_nabu' --model 'hey_jarvis' --model 'hey_rhasspy' --model 'hey_mycroft' --model 'alexa' --preload-model 'ok_nabu'    
    # --uri 'tcp://0.0.0.0:10400'
    restart: "no"
    #restart: unless-stopped
    #privileged: true
    #network_mode: host

networks:
  dhcp:
    name: "dbrv100"
    external: true
Network IP Address Gateway MAC Address Actions
dbrv100 10.0.10.100 10.0.10.1 16:a7:42:02:66:94 Leave network

Random generated MAC ================^

I use static set IP addresses by MAC dished out from DNSMasq DHCP so this breaks all the services for me as they just get random IP addresses instead of their statically defined ones.

Expected Behavior

Generate the mac_address specified.

Actual Behavior

Generates random MAC address.

Steps to Reproduce

Add a new stack, name your stack, dump the yaml above in the web editor, deploy the stack.

Portainer logs or screenshots

Client: Version: 24.0.5 API version: 1.43 Go version: go1.20.6 Git commit: ced0996600 Built: Wed Jul 26 21:44:58 2023 OS/Arch: linux/amd64 Context: default

Server: Engine: Version: 24.0.5 API version: 1.43 (minimum version 1.12) Go version: go1.20.6 Git commit: a61e2b4c9c Built: Wed Jul 26 21:44:58 2023 OS/Arch: linux/amd64 Experimental: false containerd: Version: v1.7.6 GitCommit: 091922f03c2762540fd057fba91260237ff86acb.m runc: Version: 1.1.9 GitCommit: docker-init: Version: 0.19.0 GitCommit: de40ad0

Portainer version

2.19.1

Portainer Edition

Community Edition (CE)

Platform and Version

Docker 24.0.5 | docker-compose 2.20.3

OS and Architecture

Arch Linux 6.5.5-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 23 Sep 2023 22:55:13 +0000 x86_64 GNU/Linux

Browser

Chrome Version 117.0.5938.92 (Official Build) (64-bit)

What command did you use to deploy Portainer?

Pushed the "Deploy the stack" button on the WebUI.

Additional Information

I noticed the version of compose the containers say they used seem to be perpetually set to when they were first deployed:

com.docker.compose.version | 2.20.2

Maybe this is just a database entry as when you hit redeploy it doesn’t update that field. As I have 2.20.3 of compose installed or does Portainer have it’s own docker-compose resource i.e. not /usr/bin/docker-compose etc?

I believe docker-compose had an issue https://github.com/moby/moby/pull/46406 with setting mac_address in this version. It said it was fixed 3 weeks ago maybe that is something? Does docker-compose need to be updated in Portainer to take advantage of this fix or it should use the system /usr/bin/docker-compose etc?

Thank you.

About this issue

  • Original URL
  • State: open
  • Created 9 months ago
  • Reactions: 3
  • Comments: 35

Most upvoted comments

I tested this and it’s an issue with an older version of Docker Compose, an updated version will be included in the 2.20 release which will resolve this issue.

I had this issue in a different context. I found the following and it led to the solution of my problem.

Note Container runtimes might reject this value (ie. Docker Engine >= v25.0). In that case, you should use networks.mac_address instead.

See here.

So I switched from

version: '3.8' # Example version
services:
  your_service:
    image: your_image
    mac_address: your_mac_address

to

version: '3.8' # Example version
services:
  your_service:
    image: your_image
    networks:
      default:
        mac_address: your_mac_address

Now, the mac address is correctly set in my container.

Is there an estimated release date* for 2.20 @Nick-Portainer ?

No offical date I can provide, but the team is very close 😃

Great, thanks for testing that and providing feedback that it’s now working. Please remember 2.20 is not currently released and the version I provided is just for testing 😃

Figured out the syntax I had was just wrong should have been like this for version 25:

version: '3.8'
services:
  nginx:
    image: nginx:latest
    networks:
      dhcp:
        mac_address: de:ad:be:ef:00:01
networks:
  dhcp:
    name: dbrv100
    external: true

Looks like it is working now yay!

            "Networks": {
                "dbrv100": {
                    "IPAMConfig": {},
                    "Links": null,
                    "Aliases": [
                        "mactest-nginx-1",
                        "nginx",
                        "############"
                    ],
                    "MacAddress": "de:ad:be:ef:00:01",
                    "NetworkID": "0b...",
                    "EndpointID": "75...",
                    "Gateway": "10.0.42.1",
                    "IPAddress": "10.0.42.121",
                    "IPPrefixLen": 24,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "DriverOpts": null,
                    "DNSNames": [
                        "mactest-nginx-1",
                        "nginx",
                        "############"
                    ]
                }
            }

Are you able to point to the fix in github I can’t seem to find it. Can I manually build it in some way?

Hey, so you can try our dev image of 2.20 please keep in mind this it not live and is not suitable for production and should only be used for testing, please let me know how this goes for you.

Business Edition https://hub.docker.com/r/portainerci/portainer-ee/tags portainerci/portainer-ee:2.20 Community Edition https://hub.docker.com/r/portainerci/portainer/tags docker pull portainerci/portainer:2.20

Is there an ETA on the 2.20 release?

I can’t give dates but we are now in code freeze, so it’s close 😃

I tested this and it’s an issue with an older version of Docker Compose, an updated version will be included in the 2.20 release which will resolve this issue.

I’m eager to see the fix and try again in-place. Thank you for helping me escalate this issue.

Thanks for raising this, I am going to follow this up internally and test this. I will give updates here

Still happening:

Server Version: 2.19.4	
Database Version: 2.19.4
CI Build Number: 35427	
Image Tag: linux-amd64-2.19.4

Compilation tools:
Nodejs v18.19.0
Yarn v1.22.21
Webpack v5.88.1
Go v1.20.5

I am also seeing the same issue. I ended up rolling back to 2.17.1 to restore functionality. Seems it was introduced with 2.18.0

Rather run latest patches/versions. Please advice on an eta for the fix.

Sample compose doc. Seeing the issue across all of them:

`
version: "3"
services:
  watchtower:
    image: containrrr/watchtower:latest
    container_name: watchtower-vm
    mac_address: da:de:40:30:22:ae
    environment:
      - WATCHTOWER_SCHEDULE=0 0 4 * * *
      - WATCHTOWER_CLEANUP=true
      - WATCHTOWER_INCLUDE_RESTARTING=true
      - WATCHTOWER_INCLUDE_STOPPED=true
      - WATCHTOWER_DEBUG=false
      - TZ=America/Phoenix
      - DOCKER_CONFIG=/config
    restart: unless-stopped

    networks: 
      - eth3

    volumes:
      - type: bind
        source: /var/run/docker.sock
        target: /var/run/docker.sock
      - config-data:/config/

volumes:
  config-data:
    name: docker-config
    external: true    

networks:
  eth3:
    name: qnet-dhcp-eth3-6d6da6
    external: true

`