正常启动容器
[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
宿主机访问,不能正常访问,返回Empty reply from server,一直找不到原因
[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
但进入容器内访问是可以正常返回的,bms是返回的内容
[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
使用此方式访问也不行
[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
请教一下大家,处理该问题的思路是怎样的?
It was caused by me writing the wrong listening port of nginx configuration when writing nginx.conf. I changed it to