The EXPOSE instruction is a way to document what network ports the image expects to be opened when a container is run from the image built using the Dockerfile. The syntax for the EXPOSE instruction is as follows:
# EXPOSE instruction syntax
EXPOSE <port> [<port>/<protocol>...]
It is important to understand that including the EXPOSE instruction in the Dockerfile does not actually open network ports in containers. When containers are run from the images with the EXPOSE instruction in their Dockerfile, it is still necessary to include the -p or -P parameters to actually open the network ports to the container.
You can include multiple EXPOSE instructions in your Dockerfile as needed. Including the -P parameter at runtime is a shortcut way to automatically open ports for all of the EXPOSE instructions included in the Dockerfile. The corresponding...