Solve the problem after adding --subnet to Docker network Create

Solve the problem after adding --subnet to Docker network Create

After adding –subnet to Docker network Create, use docker network ls to check. No driver is found on the newly created network. Use docker network inspect to view detailed information. You can see that there is no data in many places, especially driver. Without adding –subnet, everything is normal again.

The exception diagram is as follows:

solve

Solution: At this time, you can just change the network segment of the subnet. The reason is that the network segment specified by –subnet conflicts with the network segment of a certain network.

Additional knowledge: Networks in the docker-compose file use the already created network

Prerequisites:

Docker version: 18.06.1-ce, build e68fc7a

docker-compose version: 1.22.0, build f46880fe

Using an existing network

Create a network using docker. The following examples are given:

docker network create --driver=bridge --subnet=192.168.88.0/24 demo

Run the command to check whether the network is created successfully:

docker network ls

Using the created demo network, the docker-compose.xml is as follows:

version: "3.7"
services:
 cloudgo:
 image: cloudgo:latest
 container_name: cloudgo
 ports:
  - "8080:8080"
 logging:
  driver: "json-file"
  options:
  max-size: "1000k"
  max-file: "20" 
 networks:
  demo:
   ipv4_address: 192.168.88.80
networks:
 demo:
 external: true

The main core configuration is:

networks:
 demo:
 external: true

This part indicates the use of external network demo, and external is true. The core configuration for recreating the network is:

networks:
  demo:
   driver: default
   config:
     subnet: 172.16.238.0/24
     gateway: 172.16.238.1

demo indicates the created network suffix, the driver is set to the default value, the subnet is: 172.16.238.0/24, and the gateway is.

The above is just a brief description of the validity of the above configuration under the current docker and docker-compose versions. Other versions have not been tried, and the above method may not be applicable to other versions. I hope this can provide you with a reference, and I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • A brief discussion on the problem of Docker run container being in created state
  • docker compose idea CreateProcess error=2 The system cannot find the specified file
  • Usage instructions for the docker create command

<<:  Pay attention to the use of HTML tags in web page creation

>>:  MySQL implementation of lastInfdexOf function example

Recommend

How to set focus on HTML elements

Copy code The code is as follows: <body <fo...

Better-scroll realizes the effect of linking menu and content

1. Basic use <!DOCTYPE html> <html lang=...

Simple use of Vue bus

Simple use of Vue bus Scenario description: Compo...

Solution to the impact of empty paths on page performance

A few days ago, I saw a post shared by Yu Bo on G...

Detailed example of changing Linux account password

Change personal account password If ordinary user...

Detailed explanation of using Vue.prototype in Vue

Table of contents 1. Basic Example 2. Set the sco...

Optimizing JavaScript and CSS to improve website performance

<br /> In the first and second parts, we int...

CSS Paint API: A CSS-like Drawing Board

1. Use Canvas images as CSS background images The...

Docker container log analysis

View container logs First, use docker run -it --r...

How to quickly use mysqlreplicate to build MySQL master-slave

Introduction The mysql-utilities toolset is a col...

Screen command and usage in Linux

Screen Introduction Screen is a free software dev...

MySQL 8.0 upgrade experience

Table of contents Preface 1. First completely uni...

Zabbix configuration DingTalk alarm function implementation code

need Configuring DingTalk alarms in Zabbix is ​​s...

In-depth understanding of Vue's method of generating QR codes using vue-qr

Table of contents npm download step (1) Import (2...