Docker Networking
Docker provides an option to create and manage their own network for networking between docker containers. Use docker network subcommand to manage the Docker networking.
Syntax:
Use the below tutorial to create, list, and manage Docker networking.
List Docker Networks
Use the ls option with the docker network command to list the currently available network on the docker host.
Create Docker Network
Docker provides multiple types of networks. The below command will create a bridge network on your system.
Syntax:
Example:
Connect Container to Network
You can connect any container to an existing docker network by using the container's name or ID. Once the container is connected to the network, it can communicate with other containers in the same network.
Syntax:
Example:
Disconnect Container from Network
You can disconnect a container from the specific network at any time using the following command.
Syntax:
Example:
Inspect a Docker Network
Use inspect option with docker network comment to view the details of docker network
You will get the results like below.
Remove a Docker Network
Use rm option to remove any existing unused Docker network. You can specify one or more networks with space-separated to remove.
Example:
You can also remove all unused networks from the docker host using the prune option.
0 Comments
CAN FEEDBACK
Emoji