containers / containers/podman-compose
Multiple services cannot have the same `links` alias refer to different services
- Dominant language
- Python
- Stars
- 6.2k
- Forks
- 622
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
When multiple (source) services use the same `links` alias to refer to different (target) services, the alias ends up referring to the same target service within every source service.
**To Reproduce**
With this compose.yaml:
```yaml
services:
a:
image: "docker.io/library/alpine"
entrypoint: [ 'sleep', '600' ]
b:
image: "docker.io/library/alpine"
entrypoint: [ 'sleep', '600' ]
c:
image: "docker.io/library/alpine"
entrypoint: [ 'sleep', '600' ]
links:
- "a:foo"
d:
image: "docker.io/library/alpine"
entrypoint: [ 'sleep', '600' ]
links:
- "b:foo"
```
Steps to reproduce the behavior:
1. `podman-compose up -d`
2. Check the IP address of `foo` within `c` and `d`:
```
$ podman-compose exec c ping -c 1 foo
PING foo (10.89.0.2): 56 data bytes
64 bytes from 10.89.0.2: seq=0 ttl=42 time=0.135 ms
--- foo ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 0.135/0.135/0.135 ms
$ podman-compose exec d ping -c 1 foo
PING foo (10.89.0.2): 56 data bytes
64 bytes from 10.89.0.2: seq=0 ttl=42 time=0.118 ms
--- foo ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 0.118/0.118/0.118 ms
$
```
**Expected behavior**
`foo` is an alias to `a` (10.89.0.2) within `c`, `foo` is an alias to `b` (10.89.0.3) within `d`.
**Actual behavior**
`foo` is an alias to `a` (10.89.0.2) within both `c` and `d`.
What ends up happening is that `foo` gets 2 IP addresses within all services:
```
$ podman-compose exec d nslookup foo
Server: 10.89.0.1
Address: 10.89.0.1:53
Non-authoritative answer:
Name: foo.dns.podman
Address: 10.89.0.2
Name: foo.dns.podman
Address: 10.89.0.3
Non-authoritative answer:
$
```
**Environment:**
- OS: Ubuntu 24.10 (oracular)
- podman version: 5.0.3 (deb version: 5.0.3+ds1-5ubuntu1)
- podman compose version: 1.2.0 (deb version: 1.2.0-1)
- netavark version: 1.9.0 (deb version: 1.9.0-4)
- aardvark-dns version: 1.9.0 (deb version: 1.9.0-2)
Contributor guide
Assessment
This issue has not been assessed yet.