I'm running Podman Desktop on Windows 10, and I have set up a container to run with port mapping 8080:80. The command I use to run the container is podman run --name test -dt -p 8080:80 docker.io/nginx.
When I try to get a response from the server inside the container, it seems unable to reach the container using my PC's domain name.
curl http://localhost:8080<- Gets response from server as expectedcurl http://MOUSOURLAP-W10.domain.com:8080<- Gets connection failure
In comparison with Docker running inside WSL2, I can successfully query the server inside the container from the host (Windows) using both ways (domain name, and localhost).
I have confirmed that the Podman machine can successfully resolve my hosting machine's domain name (MOUSOURLAP-W10.domain.com) and can get a response from the container using curl http://MOUSOURLAP-W10.interamerican.gr:8080. So it seems to me that the problem probably does not have to do with Podman & container intra-networking.
I have also checked the /etc/wsl.conf and /etc/resolv.conf files inside the Podman machine and seem to be fine.
/etc/wsl.conf
[user]
default=user
/etc/resolv.conf
nameserver 172.29.224.1 #this is my host's (Windows) IPV4 address in the WSL vEthernet network
/etc/hosts
127.0.0.1 localhost
127.0.1.1 MOUSOURLAP-W10.domain.com MOUSOURLAP-W10
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
One last thing that I noticed differs between Docker and Podman is the actual ports they register for 'Listening' on the hosting machine.
- on Podman:
podman run --name test -dt -p 8080:80 docker.io/nginx netstat -an | findstr 8080 TCP 127.0.0.1:8080 0.0.0.0:0 LISTENING - on Docker:
docker run --name test -dt -p 8080:80 docker.io/nginx netstat -an | findstr 8080 TCP 127.0.0.1:8080 0.0.0.0:0 LISTENING TCP [::1]:8080 [::]:0 LISTENING
Update 1
running curl -v as @Daniel B said, to get better insight.
1.1. Running Podman container with only 8080:80 port mapping. (Connection failure)
podman run --name test -dt -p 8080:80/tcp docker.io/nginx
curl -v http://mousourlap-w10.domain.gr:8080 from host (Windows) on Podman container
* Host mousourlap-w10.domain.gr:8080 was resolved.
* IPv6: ::1
* IPv4: 192.168.1.94, 172.29.224.1
* Trying 192.168.1.94:8080...
* Trying [::1]:8080...
* connect to 192.168.1.94 port 8080 from 0.0.0.0 port 65210 failed: Connection refused
* Trying 172.29.224.1:8080...
* connect to ::1 port 8080 from :: port 65213 failed: Connection refused
* connect to 172.29.224.1 port 8080 from 0.0.0.0 port 65216 failed: Connection refused
* Failed to connect to mousourlap-w10.domain.gr port 8080 after 4081 ms: Couldn't connect to server
* Closing connection
curl: (7) Failed to connect to mousourlap-w10.domain.gr port 8080 after 4081 ms: Couldn't connect to server
1.2 Running Podman container with 8080:80 and [::1]:8080:80 port mappings (Request completely sent off).
podman run --name test -dt -p 8080:80 -p "[::1]:8080:80" docker.io/nginx
curl -v http://mousourlap-w10.domain.gr:8080 from host (Windows) to Podman container.
* Host mousourlap-w10.domain.gr:8080 was resolved.
* IPv6: ::1
* IPv4: 192.168.1.94, 172.29.224.1
* Trying 192.168.1.94:8080...
* Trying [::1]:8080...
* Connected to mousourlap-w10.domain.gr (::1) port 8080
> GET / HTTP/1.1
> Host: mousourlap-w10.domain.gr:8080
> User-Agent: curl/8.7.1
> Accept: */*
>
* Request completely sent off
And it gets stuck there forever. So it seems the request is being sent successfully to the server inside the Podman container, but never manages to get the response back.
2. Running Docker container with port mapping 8080:80 (Gets response from container server)
docker run --name test -dt -p 8080:80/tcp docker.io/nginx
curl -v http://mousourlap-w10.domain.gr:8080 from host (Windows) on Docker container
* Host mousourlap-w10.domain.gr:8080 was resolved.
* IPv6: ::1
* IPv4: 192.168.1.94, 172.29.224.1
* Trying 192.168.1.94:8080...
* Trying [::1]:8080...
* Connected to mousourlap-w10.domain.gr (::1) port 8080
> GET / HTTP/1.1
> Host: mousourlap-w10.domain.gr:8080
> User-Agent: curl/8.7.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: nginx/1.27.1
...
Related to the above, i checked Docker & Podman containers' /etc/hosts files and found a single difference that i am not sure if it affects somehow the domain name resolution.
- Podman container
etc/hosts/doesn't includelocalhostmapping for[::1]
127.0.0.1 localhost
::1 ip6-localhost ip6-loopback # <-- difference here: Podman container doesn't include localhost to [::1]
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
10.88.0.1 host.containers.internal host.docker.internal
10.88.0.11 76b1a0a497b8 test
- While, Docker container
/etc/hostsfor some reason includeslocalhostto[::1]
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback # <-- difference here: Docker container includes localhost to [::1]
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.2 5553d76d9641