containers / containers/podman-compose
Containers can not communicate via localhost/0.0.0.0/127.0.0.1 despite being in the same pod
- Dominant language
- Python
- Stars
- 6.2k
- Forks
- 622
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
A clear and concise description of what the bug is.
Rootless containers residing in the same pod can not communicate with each other via localhost/0.0.0.0/127.0.0.1 but _can_ communicate with each other via the IPs of the respective containers and the name of the containers.
Please make sure it's not a bug in podman (in that case report it to podman)
or your understanding of docker-compose or how rootless containers work (for example, it's normal for rootless container not to be able to listen for port less than 1024 like 80)
I can not recreate the issue using pure podman commands. Also [they already nacked it](https://github.com/containers/podman/issues/25372).
**To Reproduce**
Steps to reproduce the behavior:
1. what is the content of the current working directory (ex. `docker-compose.yml`, `.env`, `Dockerfile`, ...etc.)
2. what is the sequence of commands you typed
docker-compose.yaml:
```
╰─ cat docker-compose.yml
version: '3'
services:
webserver:
image: quay.io/libpod/banner
container_name: webserver-compose
client:
image: alpine
container_name: client-compose
command: sh -c "apk add curl && curl http://0.0.0.0:80"
depends_on:
- webserver
```
Then run `podman compose up`
please use [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) for example give me a small busybox-based compose yaml
**Expected behavior**
A clear and concise description of what you expected to happen.
```
╰─ podman compose up
webserver-compose
client-compose
client-compose
webserver-compose
3be54ac1b9f12ca2059b8d3169c8638a25157516a80581e87ad6ad224b39dd95
haithcockce_default
6fd7c57ba86bd52d01e7bdb8f6cefffb1971524d3221919b4796e2fa22bbdafa
178289c1e1d55631355896c0abf98bfd52114ea28faa15ed33dd0b03758f049b
313fcfb323f9cb8ed19ee5d9c2c833d48e04ca673a6c81329cb52b522c23009b
[client] | fetch https://dl-cdn.alpinelinux.org/alpine/v3.21/main/x86_64/APKINDEX.tar.gz
[client] | fetch https://dl-cdn.alpinelinux.org/alpine/v3.21/community/x86_64/APKINDEX.tar.gz
[client] | (1/9) Installing brotli-libs (1.1.0-r2)
[client] | (2/9) Installing c-ares (1.34.3-r0)
[client] | (3/9) Installing libunistring (1.2-r0)
[client] | (4/9) Installing libidn2 (2.3.7-r0)
[client] | (5/9) Installing nghttp2-libs (1.64.0-r0)
[client] | (6/9) Installing libpsl (0.21.5-r3)
[client] | (7/9) Installing zstd-libs (1.5.6-r2)
[client] | (8/9) Installing libcurl (8.12.1-r0)
[client] | (9/9) Installing curl (8.12.1-r0)
[client] | Executing busybox-1.37.0-r12.trigger
[client] | OK: 12 MiB in 24 packages
[client] | % Total % Received % Xferd Average Speed Time Time Time Current
[client] | Dload Upload Total Spent Left Speed
[client] | ___ __
[client] | / _ \___ ___/ /_ _ ___ ____
[client] | / ___/ _ \/ _ / ' \/ _ `/ _ \
[client] | /_/ \___/\_,_/_/_/_/\_,_/_//_/
[client] |
100 133 100 133 0 0 62558 0 --:--:-- --:--:-- --:--:-- 129k
^C⏎
```
**Actual behavior**
What is the behavior you actually got and that should not happen.
```
╰─ podman compose up
client-compose
webserver-compose
client-compose
webserver-compose
6fd7c57ba86bd52d01e7bdb8f6cefffb1971524d3221919b4796e2fa22bbdafa
haithcockce_default
b7a7616d1a8dcc162d0c728e17a2bcbe61fa19993731b9f1a037fefe468bf08b
da91a2484c7ffe510ccb5c6ea9d0115e61447ad86d21ed4b795ee64033bfa045
2ad97d15fd6a82451ff542f70ba272002d7f6be5b0590b15e69f0ac23ff89e89
[client] | fetch https://dl-cdn.alpinelinux.org/alpine/v3.21/main/x86_64/APKINDEX.tar.gz
[client] | fetch https://dl-cdn.alpinelinux.org/alpine/v3.21/community/x86_64/APKINDEX.tar.gz
[client] | (1/9) Installing brotli-libs (1.1.0-r2)
[client] | (2/9) Installing c-ares (1.34.3-r0)
[client] | (3/9) Installing libunistring (1.2-r0)
[client] | (4/9) Installing libidn2 (2.3.7-r0)
[client] | (5/9) Installing nghttp2-libs (1.64.0-r0)
[client] | (6/9) Installing libpsl (0.21.5-r3)
[client] | (7/9) Installing zstd-libs (1.5.6-r2)
[client] | (8/9) Installing libcurl (8.12.1-r0)
[client] | (9/9) Installing curl (8.12.1-r0)
[client] | Executing busybox-1.37.0-r12.trigger
[client] | OK: 12 MiB in 24 packages
[client] | % Total % Received % Xferd Average Speed Time Time Time Current
[client] | Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
[client] | curl: (7) Failed to connect to 0.0.0.0 port 80 after 0 ms: Could not connect to server
```
**Output**
```
╰─ podman-compose version
podman-compose version 1.3.0
podman version 5.3.2
╰─ podman --version
podman version 5.3.2
$ podman-compose up
...
```
**Environment:**
- OS: Linux / WSL / Mac
- Fedora 41
- podman version: 5.3.2
- podman compose version: (git hex) 1.3.0
**Additional context**
Add any other context about the problem here.
It seems the containers are put into two different network namespaces which may be causing this
```
watch -n 2 "podman inspect --format '{{.NetworkSettings.SandboxKey}}' client-compose; podman inspect --format '{{.NetworkSettings.SandboxKey}}' webserver-compose"
Every 2.0s: podman inspect --format '{{.NetworkSet... callisto: Thu Feb 20 13:46:46 2025
/run/user/1000/netns/netns-2d7c8419-f1bb-bea0-094a-686ae198b647
/run/user/1000/netns/netns-91d37a48-30c8-41b9-d65b-dcefa1445219
```
Contributor guide
Assessment
This issue has not been assessed yet.