Closed
Description
Describe the bug
Despite to the container used network_mode: host
default network is also applied in the command line later and has precedence!
To Reproduce
Minimal docker-compose.yml
file to reproduce problem:
version: '2.4'
services:
apache:
container_name: podman-compose-bug-reproduce
image: docker.io/httpd:2.4.52
# ports:
# - 80:80
# To use ports less than 1024 in rootless mode that require allow priveledged ports use. E.g. (or similar in sysctl.conf):
# sudo sysctl net.ipv4.ip_unprivileged_port_start=70
network_mode: host
hostname: 127.0.0.1
Run it:
$ podman-compose up -d
['podman', '--version', '']
using podman version: 3.4.4
** excluding: set()
['podman', 'network', 'exists', 'podman-compose-bug_default']
podman run --name=podman-compose-bug-reproduce -d --label io.podman.compose.config-hash=123 --label io.podman.compose.project=podman-compose-bug --label io.podman.compose.version=0.0.1 --label com.docker.compose.project=podman-compose-bug --label com.docker.compose.project.working_dir=/home/pasha/temp/podman-compose-bug --label com.docker.compose.project.config_files=docker-compose.yml --label com.docker.compose.container-number=1 --label com.docker.compose.service=apache --network host --net podman-compose-bug_default --network-alias apache --hostname 127.0.0.1 docker.io/httpd:2.4.52
72d9447da5d9680142c1ad64388d9bcff1791e0d6a2d4ba44d7094b813164667
exit code: 0
Test:
$ http http://localhost
http: error: ConnectionError: HTTPConnectionPool(host='localhost', port=80): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fe68286f070>: Failed to establish a new connection: [Errno 111] Connection refused')) while doing a GET request to URL: http://localhost/
Expected behavior
Get working Apache httpd
welcome page.
Actual behavior
Got an error what the port is not open.
Please note, in the actual command line for the podman present sequentially: --network host --net podman-compose-bug_default
, so if I manually re-run such container without --net podman-compose-bug_default
that will work:
$ podman rm -vf podman-compose-bug-reproduce
72d9447da5d9680142c1ad64388d9bcff1791e0d6a2d4ba44d7094b813164667
$ podman run --name=podman-compose-bug-reproduce -d \
--label io.podman.compose.config-hash=123 --label io.podman.compose.project=podman-compose-bug --label io.podman.compose.version=0.0.1 --label com.docker.compose.project=podman-compose-bug --label com.docker.compose.project.working_dir=/home/pasha/temp/podman-compose-bug --label com.docker.compose.project.config_files=docker-compose.yml --label com.docker.compose.container-number=1 --label com.docker.compose.service=apache \
--network host --network-alias apache \
--hostname 127.0.0.1 docker.io/httpd:2.4.52
855ef370efc9101aa69768b06f1300cf1ea5730c8e26f4e358269e23d31bc4f6
[pasha@hubbitus podman-compose-bug]$ http http://localhost
HTTP/1.1 200 OK
Accept-Ranges: bytes
Connection: Keep-Alive
Content-Length: 45
Content-Type: text/html
Date: Sun, 02 Jan 2022 15:01:26 GMT
ETag: "2d-432a5e4a73a80"
Keep-Alive: timeout=5, max=100
Last-Modified: Mon, 11 Jun 2007 18:53:14 GMT
Server: Apache/2.4.52 (Unix)
<html><body><h1>It works!</h1></body></html>
I also tested that behaviour with previous version of podman-compose
(in Fedora 35 that is 0.1.8), and it generate expected (working) run command, please look:
$ sudo dnf downgrade podman-compose -y
...
Downgraded:
podman-compose-0.1.8-1.fc35.noarch
Complete!
$ podman-compose down
...
$ podman-compose up -d
['podman', '--version', '']
using podman version: 3.4.4
** excluding: set()
podman pod create --name=podman-compose-bug --share net --infra-name=podman-compose-bug_infra
6aaa607fc4e2f6281d8a8b49f6005f65eb80c78fe575f17c1a8e68cd36c13d4e
exit code: 0
podman run --name=podman-compose-bug-reproduce -d --pod=podman-compose-bug --label io.podman.compose.config-hash=123 --label io.podman.compose.project=podman-compose-bug --label io.podman.compose.version=0.0.1 --label com.docker.compose.project=podman-compose-bug --label com.docker.compose.project.working_dir=/home/pasha/temp/podman-compose-bug --label com.docker.compose.project.config_files=docker-compose.yml --label com.docker.compose.container-number=1 --label com.docker.compose.service=apache --network host --add-host apache:127.0.0.1 --add-host podman-compose-bug-reproduce:127.0.0.1 --hostname 127.0.0.1 docker.io/httpd:2.4.52
4ea496ef388f8c20793f8a6027d3308f8a5e3f0af2ef4c25008819930442a6a9
exit code: 0
[pasha@hubbitus podman-compose-bug]$ http http://localhost
HTTP/1.1 200 OK
...
<html><body><h1>It works!</h1></body></html>
Versions and environment
$ podman-compose version
using podman version: 3.4.4
podman-composer version 1.0.3
podman --version
podman version 3.4.4
exit code: 0...
Environment:
- OS: Fedora Linux 35
- podman version: 3.4.4
- podman compose version: 1.0.3