We cant remove all the default Docker Network

Docker Bridge Network

  • When we create a Docker Container inside this network

  • A Network Interface is created on the Host Machine which is 7, master is docker0 which is 3, as shown below

  • A network interface which is 6, is also created inside the docker container, as shown below

  • There is a Virtual Ethernet that connects the 2 network interface mentioned above

  • Network communication from containers to host machine and the internet

Docker Host Network

  • When we create a Docker Container inside this network, the container is basically an application running inside the host machine, sharing the same Network Interface as the host machine. That means in the host machine, we can access the container on localhost:8080 if the the container is running on port 8080 without the need to tell docker to bridge the port between the host and container
  • The container is able to access other applications running on the host port via localhost:<PORT_OF_OTHER_APP_RUNNING_ON_HOST>

Docker Null Network

Useful Docker Network Command

Read Docker Network Info

  • List all Docker Networks
sudo docker network ls
  • Inspect a Docker Network
sudo docker network inspect <NETWORK_NAME>

Use Docker Network

docker run -d --network host hashicorp/vault server

Create/Delete Docker Network

# -d here refers to the driver Docker uses to create the network
# This will create a network interface on host machine similar to the docker0 network interface
sudo docker network create -d <NETWORK_DRIVER> <NETWORK_NAME>
  • Remove a Docker Network
sudo docker network rm <NETWORK_NAME>