Using a Docker Bridge Network

30 minutes
  • 4 Learning Objectives

About this Hands-on Lab

By default, all containers on a host can communicate with one another over a default bridge network. However, in some cases, you may want to isolate groups of containers by allowing them to communicate over their own isolated network.

In this lab, you will have the opportunity to create a custom bridge network designed to facilitate communication between containers on a Docker host.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create the bridge network.
  1. Create a bridge network called prices-net.

    docker network create --driver bridge prices-net
Create the base-price container.
  1. Create a container for the component that serves base prices.

    docker run --name base-price -d --network prices-net linuxacademycontent/prices-base-price:1
Create the sales container.
  1. Create a container for the component that serves products on sale.

    docker run --name sales -d --network prices-net linuxacademycontent/prices-sales:1
Create the total-price container.
  1. Create a container for the component that serves the total prices of products.

    docker run --name total-price -d --network prices-net -p 8080:80 linuxacademycontent/prices-total-price:1
  2. Verify that everything is set up correctly.

    curl localhost:8080

    You should get a list of products and their final prices. The total-prices container calculates these prices by first querying the other two containers. This communication takes place over the prices-net bridge network.

Additional Resources

Your fruit stand company has a Docker server set up to run three application components. There is a base-price component which serves a list of the base prices for the products sold at the fruit stand. There is also a sales component which provides a list of products that are on sale and their discount percentages. Finally, there is a total-price component that queries data from the other two services and calculates the total price for each item, including the discounts from sales.

You have been asked to configure these three components by running containers on the Docker server. They need to communicate with each other using their own bridge network, which you will also need to create. A Docker server has been made available for you to use.

Configure these application components on the Docker server so that the following specifications are met:

  • Create a bridge network called prices-net.
  • Run a container called base-price with the linuxacademycontent/prices-base-price:1 image. Configure this container to use the prices-net network.
  • Run a container called sales with the linuxacademycontent/prices-sales:1 image. Configure this container to use the prices-net network.
  • Run a container called total-price with the linuxacademycontent/prices-total-price:1 image. Configure this container to use the prices-net network. Publish this container's port 80 to port 8080 on the host.

If everything is set up correctly, you should be able to access the total prices list with curl localhost:8080.

If you get stuck, feel free to check out the solution video, or the detailed instructions under each objective. Good luck!

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Get Started
Who’s going to be learning?

How many seats do you need?

  • $499 USD per seat per year
  • Billed Annually
  • Renews in 12 months

Ready to accelerate learning?

For over 25 licenses, a member of our sales team will walk you through a custom tailored solution for your business.


$2,495.00

Checkout
Sign In
Welcome Back!
Thanks for reaching out!

You’ll hear from us shortly. In the meantime, why not check out what our customers have to say about ACG?