0
0
Dockerdevops~10 mins

Creating custom bridge networks in Docker - Visual Walkthrough

Choose your learning style9 modes available
Process Flow - Creating custom bridge networks
Start
Run: docker network create --driver bridge my_bridge
Docker creates new bridge network
Network available for containers
Containers connect to custom bridge
End
This flow shows how Docker creates a custom bridge network and how containers can connect to it.
Execution Sample
Docker
docker network create --driver bridge my_bridge

docker network ls

docker run -dit --name container1 --network my_bridge alpine sh
Creates a custom bridge network, lists networks, and runs a container connected to the custom bridge.
Process Table
StepCommandActionResult
1docker network create --driver bridge my_bridgeCreate a new bridge network named 'my_bridge'Network 'my_bridge' created
2docker network lsList all Docker networksShows 'my_bridge' among default networks
3docker run -dit --name container1 --network my_bridge alpine shRun container 'container1' attached to 'my_bridge'Container 'container1' runs connected to 'my_bridge'
4docker network inspect my_bridgeInspect network detailsShows container1 connected to 'my_bridge'
5docker network create --driver bridge my_bridgeTry to create network with existing nameError: network with name 'my_bridge' already exists
💡 Execution stops after network creation and container run; duplicate network creation fails.
Status Tracker
VariableStartAfter Step 1After Step 3Final
Networksdefault, bridge, host, nonedefault, bridge, host, none, my_bridgedefault, bridge, host, none, my_bridgedefault, bridge, host, none, my_bridge
Containersnonenonecontainer1 (on my_bridge)container1 (on my_bridge)
Key Moments - 2 Insights
Why does the second 'docker network create' command fail?
Because a network named 'my_bridge' already exists as shown in execution_table step 5, Docker prevents duplicate network names.
How do we know the container is connected to the custom bridge network?
In execution_table step 4, inspecting 'my_bridge' shows 'container1' connected, confirming the container uses the custom network.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the result of step 2?
AShows 'my_bridge' among default networks
BCreates a new container
CDeletes the network
DFails with error
💡 Hint
Check the 'Result' column in execution_table row for step 2
At which step does the container 'container1' start running?
AStep 1
BStep 3
CStep 2
DStep 4
💡 Hint
Look at the 'Action' and 'Result' columns for when the container is created
If you rename the network in step 1 to 'custom_net', what changes in the execution table?
AThe container connects to default bridge
BThe container name changes
CThe network name in step 1 and 2 results changes to 'custom_net'
DNo changes at all
💡 Hint
Focus on the network name in the 'Command' and 'Result' columns of steps 1 and 2
Concept Snapshot
Create a custom bridge network with:
  docker network create --driver bridge <name>
List networks:
  docker network ls
Run container on custom network:
  docker run --network <name> ...
Avoid duplicate network names to prevent errors.
Full Transcript
This lesson shows how to create a custom Docker bridge network named 'my_bridge'. First, the command 'docker network create --driver bridge my_bridge' creates the network. Then, 'docker network ls' lists all networks including the new one. Next, a container named 'container1' is run attached to 'my_bridge' using 'docker run -dit --name container1 --network my_bridge alpine sh'. Inspecting the network confirms the container is connected. Trying to create the same network again causes an error because the name is already taken. Variables tracked include the list of networks and containers connected. Key points include understanding why duplicate network creation fails and how to verify container network connection. The quizzes test understanding of the execution steps and effects of changing network names.