Docker Networking – Single Host Network

docker info –> will show complete docker infra details on the machine where docker installed.

Single Host:

  • only limited to the machine where docker installed.
  • containers on another machine can’t connect using this.
  • 802.1d bridge driver — a.k.a virtual switch / vswitch
  • this bridge is kernel feature on Linux

to create a docker network:

docker network create -d bridge --subnet 10.0.0.1/24 ps-bridge
to list all docker networks:
docker network ls

to get details of a particular network got from ls command:

docker network inspect ps-bridge

let’s check from kernel networks:

sudo apt-get install bridge-utils #to install network bridge utilitites on ubuntu
brctl show #will show kernel bridges and the default docker0 bridge network shown along with the bridge network we created.

docker run -dt –name c1 –network ps-bridge alpine sleep 1d
docker run -dt –name c2 –network ps-bridge alpine sleep 1d

2 containers created with the same network

docker network inspect ps-bridge

brctl show –> in the network, we can see the 2 interfaces created connected to ps-bridge switch.

docker exec -it c1 sh ##try to ping(both with name and ip) the other container.

———–

docker run -d –name web1 –network ps-bridge -p 5000:8080

Leave a comment

Blog at WordPress.com.

Up ↑