containers / containers/podman-compose

podman-compose ignores ipv4_address setting

Open
#1,090 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
6.2k
Forks
622
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

When assigning a static IP address to a container in a compose, the IP address is ignore and the first available IP address for the network is used.

**To Reproduce**

Directory contains only `compose.yml`, `Containerfile`, and `unbound.conf`.

The compose file is:

```yaml
name: dnsexample
networks:
externaldns:
driver: bridge
disable-dns: true
ipam:
config:
- subnet: 192.168.155.0/24
gateway: 192.168.155.1
services:
nameserver:
container_name: unbound
hostname: unbound.ipa.test
image: fedora:latest
network:
externaldns:
ipv4_address: 192.168.155.250

```

The container file is irrelevant, as the behavior can be seen with any image.

The `podman-compose up` command results in success:

```
$ podman-compose -f compose.yml up -d --build
STEP 1/8: FROM alpine:latest
STEP 2/8: RUN apk add --no-cache unbound
fetch https://dl-cdn.alpinelinux.org/alpine/v3.21/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.21/community/x86_64/APKINDEX.tar.gz
(1/7) Installing dnssec-root (20190225-r2)
(2/7) Installing libevent (2.1.12-r7)
(3/7) Installing libexpat (2.6.4-r0)
(4/7) Installing nghttp2-libs (1.64.0-r0)
(5/7) Installing protobuf-c (1.5.0-r2)
(6/7) Installing unbound-libs (1.22.0-r0)
(7/7) Installing unbound (1.22.0-r0)
Executing unbound-1.22.0-r0.pre-install
Executing busybox-1.37.0-r8.trigger
OK: 11 MiB in 22 packages
--> 944a7066acd7
STEP 3/8: RUN touch /var/log/unbound.log && chmod 775 /var/log/unbound.log && chown root:unbound /var/log/unbound.log
--> b39725d6e9aa
STEP 4/8: COPY extras/unbound.conf /etc/unbound/unbound.conf
--> 21b6c13ce869
STEP 5/8: RUN chmod 644 /etc/unbound/unbound.conf
--> d7bcf7f3e2b3
STEP 6/8: ADD https://www.internic.net/domain/named.root /etc/unbound/root.hints
--> e6d2ea05d730
STEP 7/8: RUN chmod 644 /etc/unbound/root.hints
--> e8fafdefa90c
STEP 8/8: ENTRYPOINT ["unbound", "-c", "/etc/unbound/unbound.conf", "-d", "-v"]
COMMIT nameserver
--> b9b8861e2b05
Successfully tagged localhost/nameserver:latest
b9b8861e2b05fd9207a21a441d04c1fa4f2daf6117c340820976806026b2a0b4
138d69839a15c5fe281e15b090e9006d7fc1685fabb8fc39053d8de663ce47c9
162e2da5423059d6d90134fac9f7cbda686b9800b67421a7ac7be3260bf42fbb
unbound
```

But when retrieving the IP address the result is:

```
$ podman exec unbound ip addr
1: lo: mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0@if4: mtu 1500 qdisc noqueue state UP qlen 1000
link/ether 5e:73:e3:77:ab:20 brd ff:ff:ff:ff:ff:ff
inet 192.168.155.2/24 brd 192.168.155.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::5c73:e3ff:fe77:ab20/64 scope link
valid_lft forever preferred_lft forever
```

A similar configuration works correctly using quadlets.

**Expected behavior**

It is expected that the defined IP address is assigned to the container.

**Actual behavior**

The "first" available IP address is assigned to the container.

**Output**

```
$ podman-compose -v
podman-compose version 1.2.0
podman version 5.3.1
...

**Environment:**
- OS: Linux Fedora 41 (updated as of 2024-12-14)
- podman version: 5.3.1
- podman compose version: 1.2.0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.