This is for communicating with other containers, not with the outside world. There are two ways to handle ports in Docker: exposing the ports and publishing the ports.Įxposing a port simply means letting others know on which port the containerized application is going to be listening on, or accepting connections on.
I'll go on to the difference between exposing and publishing ports, why they are used and how to use them. In this tutorial, I'll discuss dealing with ports in Docker. This internal and external communication is handled with exposed and published ports in Docker respectively. In the same setup, some containers also interact with the outside world. In a multi-container setup, the services running in the containers communicate with each other over a common network.