Launch a Container on the Default Network
1. Understanding the Docker Network Command
The Docker Network command is the main command that would allow you to create, manage, and configure your Docker Network. Let’s see what the sub-commands can be used with the Docker Network command. to know more about Creating a Network in Docker and Connecting a Container to That Network.
sudo docker network
We will see all the Network sub-commands one by one.
2. Using Docker Network Create command
With the help of the “Create” command, we can create our own docker network and can deploy our containers in it.
sudo docker network create --driver <driver-name> <bridge-name>
3. Using the Docker Network Connect command
Using the “Connect” command, you can connect a running Docker Container to an existing Network.
sudo docker network connect <network-name> <container-name or id>
In this example, we will connect an Ubuntu Container to the Bridge Network we created in the last step.
4. Using the Docker Network Inspect command
Using the Network Inspect command, you can find out the details of a Docker Network.
sudo docker network inspect <network-name>
You can also find the list of Containers that are connected to the Network.
5. Using the Docker Network ls command
To list all the Docker Networks, you can use the list command.
sudo docker network ls
6. Using the Docker Network Disconnect command
The disconnect command can be used to remove a Container from the Network.
sudo docker network disconnect <network-name> <container-name>
7. Using the Docker Network rm command
You can remove a Docker Network using the rm command.
sudo docker network rm <network-name>
Note that if you want to remove a network, you need to make sure that no container is currently referencing the network.
8. Using the Docker Network prune command
To remove all the unused Docker Networks, you can use the prune command.
sudo docker network prune
To know more about Docker-published ports refer to this article Docker – Managing Ports
Docker Networking
Pre-requisite: Docker
Docker Networking allows you to create a Network of Docker Containers managed by a master node called the manager. Containers inside the Docker Network can talk to each other by sharing packets of information. In this article, we will discuss some basic commands that would help you get started with Docker Networking.