docker:当尝试连接到发布的端口时,拒绝连接 [英] docker: Says connection refused when attempting to connect to a published port
问题描述
Dockerfile
FROM centos:最新
运行yum安装epel-release -y
运行yum安装wget -y
运行yum安装httpd -y
EXPOSE 80
ENTRYPOINT [/ usr / sbin / httpd,-D,FOREGROUND ]
然后我建立它:
> docker build。
然后我标记:
docker标签17283f566320我的:apache
然后我运行它:
> docker run -p 80:9191 my:apache
AH00558:httpd:使用172.17.0.2无法可靠地确定服务器的完全限定域名。设置全局的ServerName指令以抑制此消息
然后运行....
在另一个终端窗口中,我尝试发出 curl
命令查看默认网站。
>卷曲-XGET http ://0.0.0.0:9191
curl:(7)无法连接到0.0.0.0端口9191:连接拒绝
> curl -XGET http:// localhost:9191
curl:(7)无法连接到本地端口9191:拒绝连接
>卷曲-XGET http://127.0.0.1:9191
curl:(7)无法连接到127.0.0.1端口9191:拒绝连接
或者我尝试localhost
只是为了确保我的端口正确,我运行这个:
> docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5aed4063b1f6 my:apachep/ usr / sbin / httpd -DF43 seconds ago Up 42 seconds 80 / tcp,0.0.0.0:80- > 9191 / tcp angry_hodgkin
我的端口被撤销:
>码头运行-p 9191:80我的:apache
I'm a newbie at docker. I'm creating a Hello, World example. All I'm trying to do is bring up Apache in a docker and then view the default website from the host machine.
Dockerfile
FROM centos:latest
RUN yum install epel-release -y
RUN yum install wget -y
RUN yum install httpd -y
EXPOSE 80
ENTRYPOINT ["/usr/sbin/httpd", "-D", "FOREGROUND"]
And then I build it:
> docker build .
And then I tag it:
docker tag 17283f566320 my:apache
And then I run it:
> docker run -p 80:9191 my:apache
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
It then runs....
In another terminal window, I attempt to issue the curl
command to view the default web site.
> curl -XGET http://0.0.0.0:9191
curl: (7) Failed to connect to 0.0.0.0 port 9191: Connection refused
> curl -XGET http://localhost:9191
curl: (7) Failed to connect to localhost port 9191: Connection refused
> curl -XGET http://127.0.0.1:9191
curl: (7) Failed to connect to 127.0.0.1 port 9191: Connection refused
or I try localhost
Just to make sure that I got the port correct, I run this:
> docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5aed4063b1f6 my:apachep "/usr/sbin/httpd -D F" 43 seconds ago Up 42 seconds 80/tcp, 0.0.0.0:80->9191/tcp angry_hodgkin
Thanks to all. My ports were reversed:
> docker run -p 9191:80 my:apache
这篇关于docker:当尝试连接到发布的端口时,拒绝连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!