# Bridge Networking in Docker: An Overview of Network Isolation in a Container Environment

In the world of Docker, deploying a container is not simple; properly configuring a container architecture requires strong networking capabilities. A web application with a cluster of databases, applications, and load balancers spanning numerous containers that need to communicate with one another would have a different network architecture than one designed to run on a single Docker container.

Networking allows containers to communicate with each other and with the host system. Containers run isolated from the host system and need a way to communicate with each other and with the host system.

## **Docker's Default Networks**[**​**](https://refine.dev/blog/docker-networking/#none)

Three network drivers/inte[r](https://refine.dev/blog/docker-networking/#none)faces with different use cases are automatically created for you when you install Docker:

![Docker Networks - Bridge driver network - 2020](https://bogotobogo.com/DevOps/Docker/images/Docker-Network/docker0-bridge.png align="left")

### **Bridge (docker0)**[**​**](https://refine.dev/blog/docker-networking/#bridge-docker0)

A conta[i](https://refine.dev/blog/docker-networking/#none)ner connects to this network when it starts running without specifying a network. Containers connected to the bridge network are given an internal IP address to communicate with each other.

### **Host**[**​**](https://refine.dev/blog/docker-networking/#host)

A container shares the networking namespace of the host when using the host network mode. As a result, the host's IP address and port will be used by the container to isolate and execute the process directly on the host.

### **None**[**​**](https://refine.dev/blog/docker-networking/#none)

As the name indicates, this mode disables the networking stack of the container. The host, other containers, and external systems are all inaccessible to containers running without network. It becomes useful when you do not require any network connectivity or complete isolation.

To view all networks, including the default ones, you can use the command:

```bash
docker network ls
```

The output is as:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1706005449597/672af02c-356e-491d-a151-691f42d330e8.png align="center")

### Bridge Networking; An interactive demo

The default network mode in Docker. It creates a private network between the host and containers, allowing containers to communicate with each other and with the host system.

![image](https://user-images.githubusercontent.com/43399466/217745543-f40e5614-ac34-4b78-85a9-91b24512388d.png align="left")

If you want to secure your containers and isolate them from the default bridge network, you can also create your own bridge network.

```bash
docker network create -d bridge <my_bridge_name>
```

Now, if you list the available networks, the new bridge is added.

```bash
docker network ls

NETWORK ID          NAME                DRIVER
xxxxxxxxxxxx        bridge              bridge
xxxxxxxxxxxx        my_bridge_name      bridge
xxxxxxxxxxxx        none                null
xxxxxxxxxxxx        host                host
```

Now, if you want to see containers' details in the bridge network, you can use the following command:

```bash
docker network inspect bridge
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1706005764661/7986e1e7-8a67-48f2-a8aa-84da4a617968.png align="center")

For a demo, we run two containers named viz. login and logout using command:

```bash
docker run -d --name login nginx:latest
docker run -d --name logout nginx:latest
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1706006131262/214d17f8-40db-47b3-9f8d-0d2f0820cbe5.png align="center")

Now, if we hop in to the running login container using command:

```bash
docker exec -it login /bin/bash
```

Currently the running containers are:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1706006264717/9b2936df-da80-48ad-8a99-ba27559c701d.png align="center")

Now, if we run the command

```bash
docker inspect logout
```

We see that its IP address is 172.17.0.1

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1706006345203/fda77b12-caf9-4ced-8db8-1e0349f51b0f.png align="center")

Now returning back to the interactive bash of login, if we ping the IP address of logut (172.17.0.1), we get:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1706006463897/52c3f9c0-3369-44a1-970f-6dafd0849ced.png align="center")

This means that, both the login and logout are now connected via a bridge network.

Now, we create a new network named secure-network using the command:

```bash
docker network create secure-network
```

Now, in this network, we isolate a new container named finance.

We run a new named container named finance under this network using the command:

```bash
docker run -d --name finance --network=secure-network nginx:latest
```

Now, if we inspect the info of this container using command:

```bash
docker inspect finance
```

We see that the IP of this container is in new subnet, which in our case is 172.19.0.1

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1706006770648/96a46fba-5056-42be-b78d-3298ebc6370c.png align="center")

Moreover, the network is also secure-network (for previous one, it was bridge).

Now, if we ping this from the login interactive bash, we cannot get any info of this container. This implies that our container is isolated from the other two. This enhances the security too.

In this way, we created the three containers, among which two were in same subnet and one was isolated from the other two.
