skip to Main Content

I run nginx container on my azure Vm, centos 7 with this command:

docker run --name nginx2 --detach -p 0.0.0.0:90:80 nginx

Now If I run this command on the host machine: curl localhost:90 I got the error:

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

What I tried:

  1. On my local machine

I follow the same steps on my local machine and everything works like a charm. So the nginx image is not the problem

  1. Inside the container

On my VM, I connect to the nginx container and run the command : curl localhost:80 and got the answer. So nginx listen on port 80.

  1. From another container

If I create a second container and run the command curl <nginx-ip>:80. I got the result. So nginx not listen only on localhost, but on all ip.

  1. host network

When I run the container using Host Newtork --network host, everything work fine. But I don’t want to do that

  1. Try with another container
    I try using this container: docker run -p 8000:8000 -it python:3.7-slim python3 -m http.server --bind 0.0.0.0. But same error.

My question is what is the problem with bridge network on Centos ?

2

Answers


  1. I had similar problem with CentOS 7.1 and latest Docker 19.03.

    Only way I was able to resolve this was to revert to Docker 18.03 (other versions might also work). After uninstalling current Docker I installed earlier version:
    yum install docker-ce-18.03.1.ce-1.el7.centos

    After this curl localhost:<port> started to work ok with the nginx.

    Login or Signup to reply.
  2. I faced the same problem with 3000 and 80 port, add your ports to the firewal records like that:

    firewall-cmd --permanent --zone=trusted --change-interface=docker0
    firewall-cmd --permanent --zone=trusted --add-port=80/tcp
    firewall-cmd --permanent --zone=trusted --add-port=90/tcp
    firewall-cmd --reload
    

    also check if you have iptables – disable it

    systemctl disable iptables.service
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search