【发布时间】:2016-05-11 23:03:15
【问题描述】:
我是 docker 的新手。我正在创建一个 Hello, World 示例。我要做的就是在 docker 中启动 Apache,然后从主机查看默认网站。
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"]
然后我构建它:
> docker build .
然后我标记它:
docker tag 17283f566320 my:apache
然后我运行它:
> 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
然后运行....
在另一个终端窗口中,我尝试发出curl 命令来查看默认网站。
> 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
或者我尝试本地主机
为了确保端口正确,我运行了这个:
> 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
【问题讨论】:
-
您的端口错误。应该是 9191:80。
-
你的 apache 配置是怎么说的?监听的端口是什么。
标签: apache docker centos centos7