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

Detailed process of getting started with docker compose helloworld

Prerequisites Compose is a tool for orchestrating...

HTML is something that web page creators must learn and master.

What are the benefits of learning HTML? 1: Easily...

Mysql accidental deletion of data solution and kill statement principle

mysql accidentally deleted data Using the delete ...

Ten important questions for learning the basics of Javascript

Table of contents 1. What is Javascript? 2. What ...

Analysis of the operating principle and implementation process of Docker Hub

Similar to the code hosting service provided by G...

Some suggestions for improving Nginx performance

If your web application runs on only one machine,...

Detailed explanation of how to write mysql not equal to null and equal to null

1. Table structure 2. Table data 3. The query tea...

JavaScript implementation of the back to top button example

This article shares the specific code for JavaScr...

Detailed explanation of the 14 common HTTP status codes returned by the server

HTTP Status Codes The status code is composed of ...

VUE realizes registration and login effects

This article example shares the specific code of ...

Use of Linux sed command

1. Function Introduction sed (Stream EDitor) is a...

Demystifying the HTML 5 Working Draft

The World Wide Web Consortium (W3C) has released a...

How to use nginx to intercept specified URL requests through regular expressions

nginx server nginx is an excellent web server tha...

Methods for deploying MySQL services in Docker and the pitfalls encountered

I have been learning porters recently. I feel lik...