Network in Docker ( Part 1)
- Single Host Networking:
- Bridge network: The default network type in Docker which allows containers to communicate with each other on the same host.
- Host network: This network mode allows containers to share the host network stack, giving them direct access to the host's network interfaces.
- Macvlan network: This network mode assigns a unique MAC address to each container, making them appear as separate physical devices on the network.
- None: Disables all networling for a container.
- Multi Host Networking:
- Overlay : is used to share network stack of one container with others, essentially allowing contianers to communicate over the same network interface as if they were part of single host.
This part will focus on bridge mode:
Step 1: List the network which have in docker with “docker network ls” command:
Step 2: Run “docker run -it -d alpine” to create a alpine container with bridge mode:
We have created an alpine ccontainer. Run "docker container ls -a" to get detail about it.
Step 3: Run “ip
a” to get the network information of host:
docker0: This is a virtual bridge that is created by Docker when it is installed on a host machine. It acts as a network bridge that allows containers to communicate with each other and with the host machine.
eth0: This is the default network interface on a host machine. When a container is created, Docker assigns a virtual network interface named eth0 to the container, which allows it to communicate with the outside world.
vethxxx: Virtual Ethernet devices are pairs of virtual network interfaces that are linked together. In Docker, when a container created, a virtual network interface named eth0 within the container is processed, and a corresponding vethxx device is establish on the host machine, which is connected to the docker0 bridge.
Inshort,
docker0, eth0, and veth devices work together to allow communication between
containers, between containers and the host machine, and between containers and
the outside world. The docker0 bridge acts as a gateway for the containers to
communicate with each other and with external networks, and the veth devices
facilitate the communication between the containers and the host machine.
Comments
Post a Comment