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:
- 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
- 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.
- 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.
- host network
When I run the container using Host Newtork --network host
, everything work fine. But I don’t want to do that
- 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
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.I faced the same problem with 3000 and 80 port, add your ports to the firewal records like that:
also check if you have iptables – disable it