Container Networking Basics
A real application is several containers — web, api, and a database — and you must decide who talks to whom. In this lesson we build the network model: a Docker network is a private bridge that connects some containers and isolates them from everything else. We create one with docker network create,
A Docker network is like a private meeting room: whoever is inside can talk to anyone in the room, and whoever is outside hears nothing. One door (-p) leads out to the hallway (the host) — and you open it only when someone outside truly needs to come in.
- Docker network
- A private bridge network you create with docker network create and attach containers to; only the attached containers can see each other, and everything else is isolated from them.
- bridge network
- The user-defined network type that connects containers on the same host into a shared private network, separate from the host itself.
- publish port (-p)
- The -p host:container flag that crosses the boundary to the host and maps a host port to a container port, so something outside the network (for example a browser) can reach the service. You publish only what must be external.