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

JavaScript to implement the back to top button

This article shares the specific code for JavaScr...

Implementing password box verification information based on JavaScript

This article example shares the specific code of ...

A detailed explanation of the subtle differences between Readonly and Disabled

Readonly and Disabled both prevent users from chan...

Linux CentOS MySQL database installation and configuration tutorial

Notes on installing MySQL database, share with ev...

Experience in designing a layered interface in web design

Many netizens often ask why their websites always ...

How to change the domestic image source for Docker

Configure the accelerator for the Docker daemon S...

Detailed steps for building a React application with a Rails API

Table of contents Backend: Rails API part Front-e...

Docker compose custom network to achieve fixed container IP address

Due to the default bridge network, the IP address...

Two ways to exit bash in docker container under Linux

If you want to exit bash, there are two options: ...

The front-end page pop-up mask prohibits page scrolling

A problem that front-end developers often encount...

CSS performance optimization - detailed explanation of will-change usage

will-change tells the browser what changes will h...

Not all pop-ups are rogue. Tips on designing website pop-ups

Pop-up news is common in domestic Internet servic...