Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to set mac address with docker-compose #16411

Closed
desultory-zz opened this issue Nov 4, 2022 · 3 comments · Fixed by #16745
Closed

Unable to set mac address with docker-compose #16411

desultory-zz opened this issue Nov 4, 2022 · 3 comments · Fixed by #16745
Assignees
Labels
In Progress This issue is actively being worked by the assignee, please do not work on this at this time. kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@desultory-zz
Copy link

desultory-zz commented Nov 4, 2022

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind bug

Description

I'm unable to set a static MAC address to containers using docker-compose

Steps to reproduce the issue:

  1. Deploy bridge network
  2. Start podman-docker
  3. Ensure network is crated with podman network ls and podman network inspect pod-bridge
  4. Start the container with docker-compose start

Describe the results you received:

Recreating alpine-custom ... done
Attaching to alpine-custom
alpine-custom    | 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
alpine-custom    |     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
alpine-custom    |     inet 127.0.0.1/8 scope host lo
alpine-custom    |        valid_lft forever preferred_lft forever
alpine-custom    |     inet6 ::1/128 scope host
alpine-custom    |        valid_lft forever preferred_lft forever
alpine-custom    | 3: eth0@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
alpine-custom    |     link/ether c2:44:d8:38:91:14 brd ff:ff:ff:ff:ff:ff
alpine-custom    |     inet 10.10.10.46/24 brd 10.10.10.255 scope global eth0
alpine-custom    |        valid_lft forever preferred_lft forever
alpine-custom    |     inet6 fe80::c044:d8ff:fe38:9114/64 scope link
alpine-custom    |        valid_lft forever preferred_lft forever
alpine-custom exited with code 0

Describe the results you expected:

Recreating alpine-custom ... done
Attaching to alpine-custom
alpine-custom    | 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
alpine-custom    |     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
alpine-custom    |     inet 127.0.0.1/8 scope host lo
alpine-custom    |        valid_lft forever preferred_lft forever
alpine-custom    |     inet6 ::1/128 scope host
alpine-custom    |        valid_lft forever preferred_lft forever
alpine-custom    | 3: eth0@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
alpine-custom    |     link/ether 32:b5:b2:55:48:72 brd ff:ff:ff:ff:ff:ff
alpine-custom    |     inet 10.10.10.53/24 brd 10.10.10.255 scope global eth0
alpine-custom    |        valid_lft forever preferred_lft forever
alpine-custom    |     inet6 fe80::c044:d8ff:fe38:9114/64 scope link
alpine-custom    |        valid_lft forever preferred_lft forever
alpine-custom exited with code 0

Additional information you deem important (e.g. issue happens only occasionally):

Output of podman version:

Version:      3.4.4
API Version:  3.4.4
Go Version:   go1.17.3
Built:        Wed Dec 31 18:00:00 1969
OS/Arch:      linux/arm64

Output of podman info:

host:
  arch: arm64
  buildahVersion: 1.23.1
  cgroupControllers:
  - cpuset
  - cpu
  - io
  - memory
  - hugetlb
  - pids
  - rdma
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: 'conmon: /usr/bin/conmon'
    path: /usr/bin/conmon
    version: 'conmon version 2.0.25, commit: unknown'
  cpus: 4
  distribution:
    codename: jammy
    distribution: ubuntu
    version: "22.04"
  eventLogger: journald
  hostname: quartz64a
  idMappings:
    gidmap: null
    uidmap: null
  kernel: 6.0.3-media
  linkmode: dynamic
  logDriver: journald
  memFree: 2836160512
  memTotal: 3917430784
  ociRuntime:
    name: crun
    package: 'crun: /usr/bin/crun'
    path: /usr/bin/crun
    version: |-
      crun version 0.17
      commit: 0e9229ae34caaebcb86f1fde18de3acaf18c6d9a
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +YAJL
  os: linux
  remoteSocket:
    exists: true
    path: /run/podman/podman.sock
  security:
    apparmorEnabled: true
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: false
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: false
  serviceIsRemote: false
  slirp4netns:
    executable: ""
    package: ""
    version: ""
  swapFree: 1958711296
  swapTotal: 1958711296
  uptime: 18h 46m 2.59s (Approximately 0.75 days)
plugins:
  log:
  - k8s-file
  - none
  - journald
  network:
  - bridge
  - macvlan
  volume:
  - local
registries: {}
store:
  configFile: /etc/containers/storage.conf
  containerStore:
    number: 3
    paused: 0
    running: 1
    stopped: 2
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /var/lib/containers/storage
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Using metacopy: "false"
  imageStore:
    number: 9
  runRoot: /run/containers/storage
  volumePath: /var/lib/containers/storage/volumes
version:
  APIVersion: 3.4.4
  Built: 0
  BuiltTime: Wed Dec 31 18:00:00 1969
  GitCommit: ""
  GoVersion: go1.17.3
  OsArch: linux/arm64
  Version: 3.4.4

Package info (e.g. output of rpm -q podman or apt list podman or brew info podman):

Listing... Done
podman/jammy,now 3.4.4+ds1-1ubuntu1 arm64 [installed]
podman/jammy 3.4.4+ds1-1ubuntu1 armhf

Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)

Yes

Additional environment details (AWS, VirtualBox, physical, etc.):
Versions:
root@quartz64a:~/podman/dnscrypt-proxy# uname -a Linux quartz64a 6.0.3-media #trunk.0080 SMP PREEMPT Sun Oct 23 18:40:39 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux
root@quartz64a:~/podman/dnscrypt-proxy# docker-compose --version docker-compose version 1.29.2, build unknown
root@quartz64a:~/podman/dnscrypt-proxy# docker --version Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg. podman version 3.4.4

Config:
/etc/cni/net.d/1-pod-brdige.conflist

{
  "cniVersion": "0.4.0",
  "name": "pod-bridge",
  "plugins": [
    {
      "type": "macvlan",
      "master": "br0",
      "ipam": {
        "type": "dhcp"
      }
    },
    {
      "type": "tuning",
      "capabilities": {
      "mac": true
      }
    }
  ]
}

Dockerfile

FROM alpine:latest
CMD ["ip", "a"]

compose.yml

version: '3.8'
services:
  alpine-custom:
    build: .
    container_name: alpine-custom
    image: alpine-custom
    init: true
    restart: unless-stopped
    mac_address: 32:b5:b2:55:48:72
    networks:
      pod-bridge:
networks:
  pod-bridge:
    driver: macvlan
    name: pod-bridge
    ipam:
      driver: default

/etc/systemd/network/br0.netdev

[NetDev]
Name=br0
Kind=bridge
MACAddress=32:b5:b2:55:48:71

/etc/systemd/network/eth0.network

[Match]
Name=eth0

[Network]
Bridge=br0

/etc/systemd/network/eth_wifi_bind.network

[Match]
Name=br0

[Network]
DHCP=ipv4

Context: wlan0 uses hostapd in bridge mode
/etc/sysctl.conf

#IPV6 Privacy
net.ipv6.conf.default.use_tempaddr = 2
net.ipv6.conf.all.use_tempaddr = 2
net.ipv6.conf.eth0.use_tempaddr = 2
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.all.accept_source_route = 0
net.ipv6.conf.all.forwarding = 0
net.ipv6.conf.default.router_solicitations = 2
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
net.ipv6.conf.eth0.disable_ipv6 = 1

#Routing
net.ipv4.ip_forward = 1
net.ipv4.conf.all.send_redirects = 1


#Performance
fs.file-max = 65535
kernel.pid_max = 65536

net.ipv4.tcp_syn_retries = 3
net.ipv4.tcp_synack_retries = 3
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_keepalive_time = 360
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_sack = 1
net.ipv4.tcp_fack = 1
net.ipv4.tcp_timestamps = 1
net.ipv4.ip_local_port_range = 1200    65000
net.core.netdev_max_backlog = 3000

#Security
fs.protected_hardlinks = 1
fs.protected_symlinks = 1
kernel.sysrq = 0
kernel.dmesg_restrict = 1
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_rfc1337 = 1
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.icmp_ignore_bogus_error_responses = 1
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.all.secure_redirects = 1
net.ipv4.conf.all.accept_source_route = 0
vm.swappiness=100
@openshift-ci openshift-ci bot added the kind/bug Categorizes issue or PR as related to a bug. label Nov 4, 2022
@rhatdan
Copy link
Member

rhatdan commented Nov 4, 2022

@baude PTAL

@github-actions
Copy link

github-actions bot commented Dec 5, 2022

A friendly reminder that this issue had no activity for 30 days.

@rhatdan
Copy link
Member

rhatdan commented Dec 5, 2022

@Luap99 PTAL

@Luap99 Luap99 self-assigned this Dec 5, 2022
@Luap99 Luap99 added the In Progress This issue is actively being worked by the assignee, please do not work on this at this time. label Dec 5, 2022
Luap99 added a commit to Luap99/libpod that referenced this issue Dec 5, 2022
docker-compose sets the mac address in the container config and not the
network endpoint config. This is ugly when you have more than one
network, in this case docker just chooses the first network.

Fixes containers#16411

Signed-off-by: Paul Holzinger <[email protected]>
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 8, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
In Progress This issue is actively being worked by the assignee, please do not work on this at this time. kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants