Home  >  Q&A  >  body text

docker不显示端口映射呢?

各位大虾好!小白我写了一个dockerfile,内容如下:

FROM ubuntu:14.04
MAINTAINER Chris Chan "chenx1242@163.com"
ENV REFRESHED_AT 2016-12-05
RUN apt-get -y update && apt-get install -y nginx
RUN mkdir -p /var/www/html/website
ADD nginx/global.conf /etc/nginx/conf.d/
ADD nginx/nginx.conf /etc/nginx/nginx.conf
EXPOSE 80

然后又在本地写了一个index.html,然后启动这个镜像却发现port那里为空,请问大神们这样情况是什么原因呢?

世界只因有你世界只因有你2705 days ago1078

reply all(2)I'll reply

  • 習慣沉默

    習慣沉默2017-04-26 09:03:22

    EXPOSE refers to which ports are open and accessible to services within the same network. But it is not open to the host machine.

    To see the port number in docker ps, you need to specify the -p or -P parameter when docker run, such as -p 80:8080 Map port 8080 in the container to port 80 of the host.

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-04-26 09:03:22

    The PORTS of docker ps displays the docker run -pspecified port mapping

    EXPOSE means a port open to other containers (not external networks), and this is not displayed in docker ps.

    reply
    0
  • Cancelreply