podman-compose
podman-compose copied to clipboard
podman-compose keeps creating new networks each time
Describe the bug
For some reason podman-compose up -d, on some hosts, decides to create a new network for every new compose.yml file.
Tested with podman-compose 1.0.3 (Debian 12 Bookworm) as well as podman-compose 1.0.6 (Debian Testing).
IMPORTANT: the issue could NOT be replicated on several hosts. It only occurred on one host out of 3. A "good" host was running Debian Testing ARM64, while the other "good" host was running Debian 12 Bookworm AMD64. The "bad" host is running Debian 12 Bookworm AMD64 which I tried to upgrade to Debian Testing AMD64, but the problem persists :(.
This seems related to the following BUG report, but that should have been fixed in 1.0.3 as well as 1.0.6. https://github.com/containers/podman-compose/issues/288
To Reproduce compose.yml
version: "3.9"
networks:
podman:
services:
nginx:
image: nginx:latest
container_name: nginx
userns_mode: "host"
ports:
- 8080:80
networks:
- podman
Run
podman-compose up -d
Expected behavior
The container to be brought up correctly using the podman network.
Actual behavior
Instead of using podman network, new networks were created for each new container.
podman@Server:~/compose/nginx-default$ podman network ls
NETWORK ID NAME DRIVER
d38eca22899b nginx-default_podman bridge
2f259bab93aa podman bridge
Output
$ podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 4.7.2
podman-compose version 1.0.6
podman --version
podman version 4.7.2
exit code: 0
$ podman-compose up
podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 4.7.2
** excluding: set()
['podman', 'ps', '--filter', 'label=io.podman.compose.project=nginx-default', '-a', '--format', '{{ index .Labels "io.podman.compose.config-hash"}}']
['podman', 'network', 'exists', 'nginx-default_podman']
['podman', 'network', 'create', '--label', 'io.podman.compose.project=nginx-default', '--label', 'com.docker.compose.project=nginx-default', 'nginx-default_podman']
['podman', 'network', 'exists', 'nginx-default_podman']
podman create --name=nginx --label io.podman.compose.config-hash=72b42b79493991c19ccec556b189e78bd0ee507eb3af6effd294e42a3591518a --label io.podman.compose.project=nginx-default --label io.podman.compose.version=1.0.6 --label [email protected] --label com.docker.compose.project=nginx-default --label com.docker.compose.project.working_dir=/home/podman/compose/nginx-default --label com.docker.compose.project.config_files=compose.yml --label com.docker.compose.container-number=1 --label com.docker.compose.service=nginx --net nginx-default_podman --network-alias nginx -p 8080:80 --userns host nginx:latest
60a6dc2a8ab8dd1ab60b762d905580ec232e245021b76976c8de7f55c4cbc063
exit code: 0
podman start -a nginx
[nginx] | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
[nginx] | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
[nginx] | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
[nginx] | 10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
[nginx] | 10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
[nginx] | /docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh
[nginx] | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
[nginx] | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
[nginx] | /docker-entrypoint.sh: Configuration complete; ready for start up
2023/12/30 19:43:30 [notice] 1#1: using the "epoll" event method
2023/12/30 19:43:30 [notice] 1#1: nginx/1.25.3
2023/12/30 19:43:30 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14)
2023/12/30 19:43:30 [notice] 1#1: OS: Linux 6.5.0-0.deb12.4-amd64
2023/12/30 19:43:30 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2023/12/30 19:43:30 [notice] 1#1: start worker processes
2023/12/30 19:43:30 [notice] 1#1: start worker process 24
2023/12/30 19:43:30 [notice] 1#1: start worker process 25
2023/12/30 19:43:30 [notice] 1#1: start worker process 26
2023/12/30 19:43:30 [notice] 1#1: start worker process 27
Environment:
- OS: Debian 12 Bookworm AMD64 / Debian Testing AMD64
- podman version: 4.3.1 (on Debian 12 Bookworm) / 4.7.2 (on Debian Testing)
- podman compose version: 1.0.3 (on Debian 12 Bookworm) / 1.0.6 (on Debian Testing or back-ported to Debian 12 Bookworm using APT Package Pinning to Testing Release)
Adding an external: true directive in the network section seems to be a workaround for the issue.
That still doesn't explain why the behavior is different between hosts though ...
Updated compose.yml file
version: "3.9"
networks:
podman:
external: true
services:
nginx:
image: nginx:latest
container_name: nginx
userns_mode: "host"
ports:
- 8080:80
networks:
- podman