Docker custom network detailed introduction

Docker custom network detailed introduction

Docker custom network

1. Introduction to custom network

1. Introduction

When starting a regular docker container, you can use --link to bind the container network, but it will be very troublesome once there are more containers. So to customize a docker network, Xiaobai recommends using the --link command.

Custom network fixes the problem that docker0 containers cannot ping each other using container names. They can only ping each other using IP. However, our custom network can ping each other using IP or container name.

2. Command

Custom network commands illustrate
docker network create Creating a custom network
docker network inspect View custom network details
docker network ls View Network List
docker network connect Different custom networks connect to each other
docker network rm Deleting a custom network

2. Create a custom network

1. Start the regular container and check whether the container can be pinged

It is found that it is not pingable. Next, we try it with --link

insert image description here

It is found that the container can be pinged after using --link. --link is recommended for novices. Next, let's try it with a custom network.

insert image description here

2. Create a custom network

docker network ls View the network list

insert image description here

There are many types of docker networks

bridge mode

host is consistent with the host network

none Empty network Do not use the network

docker network inspect View network details

insert image description here

docker network create Create a custom network

insert image description here

–driver Set the network type

–subnet Set custom ip routing network group

–gateway Set the default ip route for this network

Here I started two containers and specified the container network with –net. You can see that you can directly ping the containers in the same network. It’s very simple.

insert image description here

This is the end of this article about the detailed introduction of Docker custom network. For more relevant Docker custom network content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed introduction to the docker network configuration process
  • Docker network principles and detailed analysis of custom networks
  • Docker container custom hosts network access operation
  • Docker's four network types principle examples

<<:  Solution for using Baidu share on Https page

>>: 

Recommend

HTML tag full name and function introduction

Alphabetical DTD: Indicates in which XHTML 1.0 DT...

Detailed steps to install MySQL 8.0.27 in Linux 7.6 binary

Table of contents 1. Environmental Preparation 1....

How to build a K8S cluster and install docker under Hyper-V

If you have installed the Win10 system and want t...

How to insert batch data into MySQL database under Node.js

In the project (nodejs), multiple data need to be...

Install redis and MySQL on CentOS

1|0MySQL (MariaDB) 1|11. Description MariaDB data...

Basic usage of JS date control My97DatePicker

My97DatePicker is a very flexible and easy-to-use...

How to delete all contents in a directory using Ansible

Students who use Ansible know that Ansible only s...

Vue implements the magnifying glass effect of tab switching

This article example shares the specific code of ...

Introduction to the use of several special attribute tags in HTML

The following attributes are not very compatible w...

Docker batch start and close all containers

In Docker Start all container commands docker sta...

Detailed explanation of Vue's hash jump principle

Table of contents The difference between hash and...

Reasons and solutions for MySQL selecting the wrong index

In MySQL, you can specify multiple indexes for a ...