podman-compose
podman-compose copied to clipboard
When no network is specified and using network_mode: host, it will use unexpected default network
Describe the bug When no network is specified and using network_mode: host, it will use unexpected default network
To Reproduce Steps to reproduce the behavior:
version: "3"
services:
prometheus:
image: prom/prometheus
restart: always
network_mode: host
then podman-compose up
the image here can be replaced with busybox
Expected behavior
it should successfully use network host, the podman run commands should not contain other --net prometheus_default --network-alias prometheus prom/prometheus
args
Actual behavior
podman run args still contains: `
Output
['podman', 'network', 'exists', 'prometheus_default']
podman create --name=prometheus_prometheus_1 --label io.podman.compose.config-hash=123 --label io.podman.compose.project=prometheus --label io.podman.compose.version=0.0.1 --label com.docker.compose.project=prometheus --label com.docker.compose.project.working_dir=/root/workspace/monospace/docker/prometheus --label com.docker.compose.project.config_files=podman-compose.yml,docker-compose.yml --label com.docker.compose.container-number=1 --label com.docker.compose.service=prometheus --network host --net prometheus_default --network-alias prometheus prom/prometheus
Error: cannot set multiple networks without bridge network mode, selected mode host: invalid argument
exit code: 125
podman start -a prometheus_prometheus_1
Error: no container with name or ID "prometheus_prometheus_1" found: no such container
exit code: 125
Environment:
- OS: WSL
- podman version: 4.3.1
- podman compose version: 1.0.3
Additional context
I think the problem is in https://github.com/containers/podman-compose/blob/main/podman_compose.py#L1880
when not specifying networks, it will set a default_network and produce net args in https://github.com/containers/podman-compose/blob/main/podman_compose.py#L857