What is the use of EXPOSE in Docker file

Hi, David
Thanks for your reqly. If I understand you correctly, the two uses of EXPOSE in the dockerfile are

  1. “as a hint to the next person to maintain the system” so that they know what are the ports should be published when runs the image.

  2. When running the image with -P, the exposed ports in dockerfile will be published to avoid a long list of -p for individual ports.

Is my understanding correct? Thanks.