Docker Community Forums

Share and learn in the Docker community.

Port publishing does not work as expected (archlinux)

Hi,

I have a fresh new installation of docker and when I am running the simple command : docker run --rm -p 8080:80 -d nginx

CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS         PORTS                                   NAMES
84d00cda7c6e   nginx     "/docker-entrypoint.…"   7 minutes ago   Up 7 minutes   0.0.0.0:8080->80/tcp, :::8080->80/tcp   mystifying_hellman

When I run a curl I get this result :

curl localhost:8080
curl: (56) Recv failure: Connection reset by peer

The curl must return the nginx default page but it’s not the case. Docker inspect of the container https://pastebin.com/Hx8H7ES6

When I am using the network host with the --net host, the port 80 of nginx is available with curl localhost:80 (not localhost:8080) (so imo the issue is related to the port publishing stuff).

Ifconfig:

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        inet6 fe80::42:4cff:fe24:98d9  prefixlen 64  scopeid 0x20<link>
        ether 02:42:4c:24:98:d9  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3  bytes 346 (346.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 85  bytes 8057 (7.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 85  bytes 8057 (7.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.14  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::80db:a4ec:7627:f8f3  prefixlen 64  scopeid 0x20<link>
        inet6 2a01:cb14:4c8:fe00:c2b6:f9ff:fe8a:9535  prefixlen 64  scopeid 0x0<global>
        inet6 2a01:cb14:4c8:fe00:3192:c89e:d9cb:621a  prefixlen 64  scopeid 0x0<global>
        ether c0:b6:f9:8a:95:35  txqueuelen 1000  (Ethernet)
        RX packets 18917  bytes 4595475 (4.3 MiB)
        RX errors 0  dropped 87  overruns 0  frame 0
        TX packets 20706  bytes 4374995 (4.1 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

iptable -L:

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
DOCKER-USER  all  --  anywhere             anywhere            
DOCKER-ISOLATION-STAGE-1  all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
DOCKER     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain DOCKER (1 references)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             172.17.0.2           tcp dpt:http

Chain DOCKER-ISOLATION-STAGE-1 (1 references)
target     prot opt source               destination         
DOCKER-ISOLATION-STAGE-2  all  --  anywhere             anywhere            
RETURN     all  --  anywhere             anywhere            

Chain DOCKER-ISOLATION-STAGE-2 (1 references)
target     prot opt source               destination         
DROP       all  --  anywhere             anywhere            
RETURN     all  --  anywhere             anywhere            

Chain DOCKER-USER (1 references)
target     prot opt source               destination         
RETURN     all  --  anywhere             anywhere 
Kernel: 5.12.9-arch1-1 
Docker version: 20.10.7

Anyone could help me ? I am not good enough in networks to solve this problem alone and I think there is some good people here that can help me ! :smiley: