Difficulty: Beginner
Estimated Time: 10 minutes

This scenario explores how to create a docker network allowing containers to communicate. The network has similar attributes to a physical network, allowing containers to come and go freely. A two-node swarm cluster has already been created for you.

This scenario has explained how to use Docker Networks. Docker Networks provide a way to connect multiple containers together.

Don’t stop now! The next scenario will only take about 10 minutes to complete.

Advanced Docker Networking

Step 1 of 8

Step 1 - Using Default Bridge Network

In this step, you will run two different alpine containers on the same Docker host and do some tests to understand how they communicate with each other. You need to have Docker installed and running.

Open a terminal window. You can list current networks by running docker network ls

The default bridge network is listed, along with host and none. The latter two are not fully-fledged networks, but are used to start a container connected directly to the Docker daemon host’s networking stack, or to start a container with no network devices. This tutorial will connect two containers to the bridge network.

Task: Connect To Network

When we launch new containers, we can use the --net attribute to assign which network they should be connected else the containers connect to the default bridge network.

Running following command to start two alpine containers. docker run -dit --name alpine1 alpine ash

docker run -dit --name alpine2 alpine ash

Inspect the bridge network to see what containers are connected to it docker network inspect bridge

Port 3000
Port 8080
Port 8081