010*_*101 2 apache centos docker centos7
我是码头工人的新手。我正在创建一个“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"]
Run Code Online (Sandbox Code Playgroud)
然后我构建它:
> 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
Run Code Online (Sandbox Code Playgroud)
然后就运行了......
在另一个终端窗口中,我尝试发出命令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
Run Code Online (Sandbox Code Playgroud)
或者我尝试本地主机
为了确保端口正确,我运行以下命令:
> 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
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
26795 次 |
最近记录: |