Skip to content

mac_address not respected? #507

@mw88-personal

Description

@mw88-personal

I am trying to setup a container in a macvlan with a fixed mac_address. It works manually, but not using podman-compose.

Firstly, I am setting up the network manually:

sudo podman network create -d macvlan -o parent=enp7s0 newnet

Secondly, I make CNI plugins run as a service:

sudo nano /usr/lib/systemd/system/io.podman.dhcp.socket

[Unit]
Description=DHCP Client for CNI

[Socket]
ListenStream=%t/cni/dhcp.sock
SocketMode=0600

[Install]
WantedBy=sockets.target
sudo nano /usr/lib/systemd/system/io.podman.dhcp.service
[Unit]
Description=DHCP Client CNI Service
Requires=io.podman.dhcp.socket
After=io.podman.dhcp.socket

[Service]
Type=simple
ExecStart=/usr/libexec/cni/dhcp daemon
TimeoutStopSec=30
KillMode=process

[Install]
WantedBy=multi-user.target
Also=io.podman.dhcp.socket
sudo systemctl --now enable io.podman.dhcp.socket

I verify that I can run a test container manually and manually assign a mac_address:

$ sudo podman run -it --rm --network newnet--mac-address 12:34:56:78:9a:bc alpine ip link show
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
2: eth0@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
    link/ether 12:34:56:78:9a:bc brd ff:ff:ff:ff:ff:ff

This represents the expected output.

Now I try to do the same using podman-compose:
Create the configuration file:

# docker-compose.yml
version: '3'

services:
  alpinetest:
    hostname: alpinetest
    container_name: alpinetest
    image: alpine
    stdin_open: true
    tty: true
    command: sh
    mac_address: 12:34:56:78:9a:bc
    networks:
      - dhcp
networks:
  dhcp:
    name: newnet
    external: true

Start it:

podman-compose up
['podman', '--version', '']
using podman version: 4.1.1
** excluding:  set()
['podman', 'network', 'exists', 'newnet']
podman create --name=alpinetest --label io.podman.compose.config-hash=123 --label io.podman.compose.project=alpinetest --label io.podman.compose.version=0.0.1 --label com.docker.compose.project=alpinetest --label com.docker.compose.project.working_dir=/mnt/docker/alpinetest --label com.docker.compose.project.config_files=docker-compose.yml --label com.docker.compose.container-number=1 --label com.docker.compose.service=alpinetest --net newnet --network-alias alpinetest --hostname alpinetest -i --tty alpine sh
aea7dbeaedda66387031ea7b1c55cd628d8ef7abadb7d8fea77dff8586ead73c
exit code: 0
podman start -a alpinetest
/ #

However, when I do call inside the container's shell

/ # ip link show
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
2: eth0@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
    link/ether b2:30:1f:86:9e:73 brd ff:ff:ff:ff:ff:ff

I only get a random mac address, each time the container is started. Am I missing something, or is the mac_address property not implemented with podman-compose?

System info:

$ podman-compose --version
['podman', '--version', '']
using podman version: 4.1.1
podman-composer version  1.0.3
podman --version
podman version 4.1.1
exit code: 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions