Get the App
SLTechnology News&Howtos  ›  Development  › 

How Docker customizes the network

Shulou Source: shulou.com Published: 2022-06-02 05:57:08 10月25日 Update

This article will explain in detail how Docker customizes the network. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Docker custom network one. Introduction to Custom Network

1. Introduction

When you start a regular docker container, you can use-link to bind the container network, but once there are too many containers, it will be very troublesome, so to customize a docker network, rookies recommend using the-link command

Custom network fixed the problem that containers in docker0 cannot ping each other with container names. Only ip can be used to communicate with ping, but our custom network can communicate with each other by ip or container name.

two。 Command

Custom network command description docker network create create custom network docker network inspect view custom network details docker network ls view network list docker network connect different custom network interconnection docker network rm delete custom network II. Create a custom network

1. The regular container starts to check whether the container can ping.

It is found that it is impossible to communicate with ping, so let's try it with-link.

It is found that the container can communicate with ping after using-link.-link recommends Xiaobai to use it. Next, let's try it with a custom network.

two。 Create a custom network

Docker network ls View Network list

There are many types of docker networks.

Bridge bridging mode

The host is consistent with the host network

None empty network does not use network

Docker network inspect to view network details

Docker network create creates a custom network

-driver sets the network type

-subnet sets custom ip routing netgroups

-gateway sets the default ip route for this network

Here I start two containers and specify the network of the container with-net. You can see the container that can directly ping the same network, which is very simple.

This is the end of the article on "how to customize the network in Docker". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: Network container command article next general more type details routing rookie recommendation different good practical consistent two between content host Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Docker NVidia MySQL Shulou Technology