Docker containers leveraging VSwitch

Pallavi Sengupta
Aug 24, 2017 · 2 min read

Docker Networking on single host

When you install Docker, it creates three networks automatically. You can list these networks using the docker network ls command:

sudo docker network ls

Single host communication

  • When we launch a container, it is automatically connected to the default bridge network,unless specified
  • Containers connected to the default bridge network can communicate with each other by IP address. Docker does not support automatic service discovery on default bridge network
  • It is recommended to use user-defined bridge networks to control which containers can communicate with each other, and also to enable automatic DNS resolution of container names to IP addresses
  • This is as simple as creating our own bridge network and then launching containers on it. The scope of such a network is the docker host on which it is created
  • Creating a bridged network will create a Virtual Switch(or VSwitch) in the docker host,entirely in s/w
  • The docker bridge driver leverages the linux bridge of the kernel(for docker on linux).

Commands and steps for the above

  1. sudo docker network create -d bridge — -subnet 10.0.0.1/24 ps-bridge
sudo docker network ls

2. sudo docker run -dt — name container1 — network ps-bridge alpine sleep 1d

3. sudo docker run -dt — name container2 — network ps-bridge alpine sleep 1d

sudo docker network inspect ps-bridge

4. Checking connection

sudo docker exec –it container1 sh

)
Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade