What is the difference between `EXPOSE`, `-p` and `-P`?
BeginnerConceptNetworking
Answer
EXPOSE documents ports in the image. -p host:container publishes a specific mapping. -P publishes every exposed port to a random ephemeral host port. Only publishing makes the service reachable from outside the Docker network.
More on Networking
What network drivers does Docker have?BeginnerHow does the default bridge network work?AdvancedDefault bridge vs user-defined bridge: what is the difference?IntermediateHow does container DNS work?IntermediateHow does `-p 8080:80` work under the hood?AdvancedWhat is the difference between `-p 80:80` and `-p 127.0.0.1:80:80`?Beginner