I'm confused with the Docker doc's EXPOSE vs -p. Here's what I understand: EXPOSE serves for inter-container communication only and cannot be accessed from the outside.
But the developer guide writes "The EXPOSE instruction does not actually publish the port. It functions as a type of documentation between the person who builds the image and the person who runs the container, about which ports are intended to be published."
Does it mean that if I have EXPOSE as 8001 and -p as 8002, the -p flag will overwrite EXPOSE and the container will be published on 8002? I guess I'm confused by the word "publish".