April 2017
Beginner
404 pages
9h 30m
English
The EXPOSE instruction exposes the port for the container. It informs Docker that the container will be listening on specified ports during runtime. The -p 80:80 flag we used while creating the container will map port 80 of the container host to port 80 of the running container so that all the traffic on port 80 can be forwarded to the container's port, this is called port forwarding. It is not necessary for the container's host port to be the same as that of the container, for example, we can also do -p 5000:80. In this case, we have to reach the container by accessing port 5000 on the container host. For example, in the following instruction Docker exposes port 80 of the container:
EXPOSE 80
Read now
Unlock full access