Docker provides container isolation, one of the aspects that helps to achieve this is by using Networking namespace.
The objective is to understand how containers interact with
- Other containers
- The host and
- The host’s network i.e outside the world via the host.
- Protocol: It is like a language. Two parties will communicate using a common language. one such example is HTTPS.
- Network interface: Its more of like a mediator, without its help a device cannot talk to other network's devices, basically Network Interface Card.
There are two kinds of interfaces
a. Ethernet Interface: This helps to connect other's network interfaces.
b. Loopback Interface: Virtual network interface that a computer uses to communicate with itself.
- Networking: Its nothing but people talking and exchanging information knowing their whereabouts. Simple as that!
- Important note: Objective is containers should be able to talk, where containers are present is secondary. Hence, there two different ways of doing networking in Docker:
a. Single-host virtual networks: Containers on the same host talking to each other.
b. Multi-host network docker: Containers present on the different host wants to talk to other containers as if present on one common host.
Will try to understand it vividly in the next posts.
Right now think how it can achieve this Network connectivity and what are the network types?
There is something called as Drivers that helps to achieve Network connectivity.
The interesting part comes here- Network Types!
Run: docker network ls
$ docker network ls NETWORK ID NAME DRIVER SCOPE 0cbe40bf4969 bridge bridge local 7361f58bf7ab host host local 6051f389c7f5 none null local
Above are the default networks, which are created when we install Docker. Made our life simpler!
On macro level lets understand these Network Types
- Bridge Network:
It's a default network where containers by default get added here.
It helps containers to communicate with each other.
one can create its own bridge network and put containers into it. This is called as User-defined bridge networks.
- Host Network
Removes the isolation between docker host and its containers.
It uses Host's Networking features, hence making it impossible to run containers on the same port of the host's.
- None Network
It is more of like a closed container, where we don't want containers by any means to communicate with the outside world or its neighboring containers itself. Here is where the loopback interface is used - to communicate to itself.
- Overlay network: The host-specific networks
- Macvlan network: Communication possible by assigning MAC addresses to each container’s virtual network interface.
To understand practically click on to respective networks