问题描述
在 win7 64bit
我的代码:
docker run --name web -d -p 8000:8000 richarvey/nginx-php-fpm
我在chrome浏览器中看不到任何结果。
I can't see any result in chrome browser.
重新安装 docker工具箱
&&重新启动&&禁用防火墙没有帮助。
reinstall docker toolbox
&& reboot && disable firewall did not help.
192.168.99.100:8000
172.17.0.2:8000
localhost:8000
192.168.99.100:8000
172.17.0.2:8000
localhost:8000
docker inspect web | grep IPAddress
显示:
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.2",
"IPAddress": "172.17.0.2",
运行:
$ docker-machine ls
显示:
NAME ACTIVE DRIVER STATE URL SWARM DO
CKER ERRORS
default * virtualbox Running tcp://192.168.99.100:2376 v1
8.06.1-ce
运行:
$ docker ps
显示:
CONTAINER ID IMAGE COMMAND
CREATED
STATUS PORTS
NAMES
65b815ffa17c richarvey/nginx-php-fpm "docker-php-entrypoi" 4 hours ag
o Up 4 hours 80/tcp, 443/tcp, 9000/tcp, 0.0.0.0:8000->8000/tcp
web
更新
docker run --name web -d -p 8000:80 richarvey/nginx-php-fpm
http://192.168.99.100:8000/ <-- only this one work!
http://172.17.0.2:8000/
http://localhost:8000/
在docker内部,
-
首先检查nginx是否正在运行。
first off check if nginx is running.
查看哪个进程正在使用端口80
see which process is using port 80
bash-4.4# ps aux | grep nginx
14 root 0:00 nginx: master process /usr/sbin/nginx -g daemon off; error_
log /dev/stderr info;
15 nginx 0:00 nginx: worker process
16 nginx 0:00 php-fpm: pool www
17 nginx 0:00 php-fpm: pool www
18 nginx 0:00 php-fpm: pool www
29 root 0:00 grep nginx
bash-4.4# netstat -tulpn | grep :80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
14/stderr info;
tcp 0 0 :::80 :::* LISTEN
14/stderr info;
bash-4.4#
推荐答案
图像use在其端口80上发布NGinx端口。因此,如果要在公共端口8000上发布它,则应使用以下命令运行容器:
The image you use publishes NGinx port at its port 80. So, if you want it at your public port 8000, you should run the container with:
docker run --name web -d -p 8000:80 richarvey/nginx-php-fpm
编辑:或者(仅适用于Linux上的Docker),您可以使用以下端口访问容器的私有IP(从 docker inspect web
获取)您的浏览器:
Alternatively (only with Docker on Linux), you can access to container's private IP (taken from docker inspect web
) at port 80 with your browser: http://172.17.0.2
这篇关于如何在浏览器中查看Docker服务器内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!