JavaScript required
We’re sorry, but Coda doesn’t work properly without JavaScript enabled.
Skip to content
Gallery
DevOps
Kubernetes (K8s)
Docker
HELM
Ansible
Linux Commands
More
Share
Explore
Docker
Docker networking
Show all networks
docker network ls
filter all bridge networks
docker network ls -f driver=bridge
To find all network IDs and Drivers
docker network ls --format "{{.ID}}: {{.Driver}}"
Inspect a network(get all info about a network in json format)
docker network inspect <network_id>
Create a new network
docker network create <network_name>
Above command creates a bridge network by default if we don’t specify what kind of driver we want.
Manually creating a bridge network
docker network create -d bridge <network_name>
Connecting container to a network
docker network connect <network_name> <container_name> (We can use name or ID)
After connection, container can communicate with other containers in the same network.
Creating a container and attaching it to the network
docker container run -d --name <container_name> --network <network_name> <image>
One container can be connected to many network simultaneously (Basically Many to Many relationship)
Disconnecting a network for a container
docker network disconnect <network_name>
(network we want to disconnect)
<container_name>
Executing commands in a container
For example pinging one container from another container in the same network
docker container exec -it <container1_name>
(command to execute)
ping <container2_name>
EXAMPLE
docker container exec -it mynginx1 ping mynginx2
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
Ctrl
P
) instead.