...

/

Reviewing Network Drivers for Docker

Reviewing Network Drivers for Docker

Get to know about reviewing network drivers for Docker.

Network drivers are components that provide networking capabilities between containers. They enable containers to communicate with each other and external networks. They provide the necessary functionality to route network traffic to and from containers. Docker supports multiple network drivers, each with its features and capabilities. Some of these network drivers include the bridge, the host, and the none drivers. We’ll be examining each of them below.

Press + to interact

Bridge network driver

The bridge network driver is Docker’s default network driver. When it’s used, virtual networks are created on the host system, which allows containers to bridge communication with each other. Docker assigns IP addresses when containers are created. Those created IPs are what containers use to communicate when bridge network drivers are configured.

Press + to interact
Bridge network driver
Bridge network driver

We’ll create a bridge network and some containers and try interacting with the containers. We do that through the following below:

Note: Our bridge network is called bnet. The first container is called container1, while the second is called container2.

  • Create bridge network: We create a bridge network first before the containers, and we do that with the following command:

docker network create bnet
  • Create containers: We use the following commands to create the containers connecting them with our bridge. The containers use an Nginx image.

Press + to interact
# Command to start the first container
docker run -d --name container1 --network bnet nginx
# Command to start the second container
docker run -d --name container2 --network bnet nginx
  • Check container status: We check both containers’ status with the following command:

docker ps
  • Implement interaction within the container and with other containers: We run the following commands to confirm the interaction between containers. To enable interaction between containers, we’ll install the ping functionality.

Press + to interact
# To get into our container
docker exec -it <container_id> sh
# To install the latest updates within our container
apt-get update
# To install ping
apt-get install -y iputils-ping
# To interact with other containers
ping <container_id>
# Cancel ping operation after usage by pressing the key below
ctrl+q
# To exit the container after running all operations, we type the following command
exit

Note: Try out all commands in the terminal widget below.

Terminal 1
Terminal
Loading...

Host network

...