Last updated
Last updated
In this lab you'll look at the most basic networking components that come with a fresh installation of Docker.
You will complete the following steps as part of this lab.
You will need all of the following to complete this lab:
A Linux-based Docker Host running Docker 1.12 or higher
docker network
commandThe docker network
command is the main command for configuring and managing container networks.
Run a simple docker network
command from any of your lab machines.
The command output shows how to use the command as well as all of the docker network
sub-commands. As you can see from the output, the docker network
command allows you to create new networks, list existing networks, inspect networks, and remove networks. It also allows you to connect and disconnect containers from networks.
Run a docker network ls
command to view existing container networks on the current Docker host.
The output above shows the container networks that are created as part of a standard installation of Docker.
New networks that you create will also show up in the output of the docker network ls
command.
You can see that each network gets a unique ID
and NAME
. Each network is also associated with a single driver. Notice that the "bridge" network and the "host" network have the same name as their respective drivers.
The docker network inspect
command is used to view network configuration details. These details include; name, ID, driver, IPAM driver, subnet info, connected containers, and more.
Use docker network inspect
to view configuration details of the container networks on your Docker host. The command below shows the details of the network called bridge
.
NOTE: The syntax of the
docker network inspect
command isdocker network inspect <network>
, where<network>
can be either network name or network ID. In the example above we are showing the configuration details for the network called "bridge". Do not confuse this with the "bridge" driver.
connect - Connect a container to a network
create - Create a network
disconnect - Disconnect a container from a network
inspect - Display detailed information on one or more networks
ls - List networks
prune - Remove all unused networks
rm - Remove one or more networks
docker network inspect [NAME]
Step 1: Creating a network:
docker network rm [NAME]
Step 1: Remove all unused networks:
Step 1: Create a container with no network:
Step 2: Create a new network:
Step 3: Add the container to the bridge network:
Step 4: Inspect network-test03 to see the networks:
Step 5: Remove network-test03 from br01: