正常啟動容器
[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
請教一下大家,處理該問題的思路是怎麼樣的?
是個人寫nginx.conf 時把nginx的配置的監聽埠寫錯導致的,改為