Ref: https://learn.cantrill.io/courses/docker-fundamentals/lectures/44151341 =OR= https://www.youtube.com/watch?v=zJD7QYQtiKc
Host Networking
- ð§Â Containers share the host's NW
- Simple, no configuration
- Container Port = Host Port
- â Problems/clashes when different containers expose the same port
- e.g. running multiple containers from the same image
Bridge Networking
- ð§Â A Bridge NW is created separately inside the host
- Containers can connect to this Bridge NW
- Each container gets its own IP address on the Bridge NW
- â Containers can expose the same port numbers
- Port publishing/mapping needed for external communication
<Host_Port>:<Container_Port>
- Default communication:
- Containers on the same bridge NW can communicate
- Containers can't be reached from outside Docker Host
- Their ports must be published in the host NW before they can be reached
- Container's IP address in Bridge NW can be found by inspecting container metadata
- ð¡Â Bridge NWing has many configuration options, also one can define many Bridge NWs (details outside the scope of this Fundamentals course)
Bridge vs Host Networking Diagram
