The sink host cannot access docker’s container (nginx)

  docker, question

Start container normally

[root@iZ287mq5dooZ data]# docker run --name nginx11 -p 80:80 -d -v /www:/www -v /data:/data --link php7:php7 -it centos/nginx:v1.11.5
 9078f7a9a3550f39127ec07e734d0179453d6d1da60a141f71a14bc352bb8f5d
 [root@iZ287mq5dooZ data]# docker ps
 CONTAINER ID        IMAGE                  COMMAND                  CREATED             STATUS              PORTS                         NAMES
 9078f7a9a355        centos/nginx:v1.11.5   "/usr/local/nginx/sbi"   6 minutes ago       Up 6 minutes        0.0.0.0:80->80/tcp, 443/tcp   nginx11
 e15ebb8a53b2        centos/php:v7.0.12     "/usr/local/php/sbin/"   2 hours ago         Up 2 hours          0.0.0.0:9000->9000/tcp        php7

Host access, unable to access normally, returned Empty reply from server, unable to find reason all the time

[root@iZ287mq5dooZ data]# curl http://127.0.0.1
 curl: (52) Empty reply from server
 [root@iZ287mq5dooZ data]# curl http://127.0.0.1
 curl: (56) Recv failure: Connection reset by peer

However, access into the container can be returned normally, and bms is the returned content

[root@iZ287mq5dooZ data]# docker inspect --format "{{ .State.Pid }}"  9078f7a9a355
 22063
 [root@iZ287mq5dooZ data]# nsenter --target 22063 --mount --uts --ipc --net --pid
 [root@9078f7a9a355 /]# curl http://localhost
 bms

This method of access is not acceptable either.

[root@iZ287mq5dooZ data]# docker inspect --format='{{.NetworkSettings.IPAddress}}' 9078f7a9a355
 192.168.0.3
 [root@iZ287mq5dooZ data]# curl http://192.168.0.3
 curl: (7) Failed connect to 192.168.0.3:80;  Connection refused

May I ask everyone what is the thinking for dealing with this problem?

When writing nginx.conf, the individual writes nginx’s configured listening port incorrectly and changes it to

server {
 listen       80;  //I wrote 127.0.0.1, and other configurations are slightly different.
 }