Docker custom bridge docker0 and docker's opening, closing, and restarting command operations

Docker custom bridge docker0 and docker's opening, closing, and restarting command operations

question

After the company migrated the server, the docker0 bridge created by default conflicted with the company's external network gateway.

This results in the external network being unable to connect to the server.

Solution

Modify the default configuration file /etc/docker/daemon.json to configure Docker.

If not created directly

1. Shut down the docker service

systemctl stop docker

2. Modify bip

{
 "bip": "192.168.0.1/24", # Modify here.... 
}

3. Restart Docker

systemctl restart docker

Docker shutdown, restart, and start commands

sudo service docker stop # Shut down or sudo systemctl stop docker
sudo service docker restart # Restart or sudo systemctl restart docker
sudo service docker start # Start sudo systemctl start docker # Start

Supplement: Modify the default ip of docker0

When the Docker service is started, a docker0 bridge is created by default (with a docker0 internal interface on it), which connects other physical or virtual network cards at the kernel layer, putting all containers and the local host on the same physical network.

By default, Docker specifies the IP address and subnet mask of the docker0 interface, allowing the host and container to communicate with each other through the bridge. It also gives the MTU (the maximum transmission unit allowed to be received by the interface), which is usually 1500 Bytes, or the default value supported by the host network routing. These values ​​can be configured when the service is started.

You can edit the /etc/docker/daemon.json file and add the content "bip": "ip/netmask" [Do not use the same network segment as the host]

[root@localhost /]# vi /etc/docker/daemon.json
{"bip":"192.168.100.1/24"}

The above is my personal experience. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. If there are any mistakes or incomplete considerations, please feel free to correct me.

You may also be interested in:
  • Docker Compose network settings explained
  • A brief discussion on docker-compose network settings
  • Docker adds a bridge and sets the IP address range
  • A troubleshooting experience of centos Docker bridge mode unable to access the host Redis service
  • Docker-compose creates a bridge, adds a subnet, and deletes a network card

<<:  Use a diagram to explain what Web2.0 is

>>:  Detailed explanation of the properties and instance usage of hasOwnProperty in js

Recommend

Enable sshd operation in docker

First, install openssh-server in docker. After th...

Detailed explanation of adding click event in echarts tooltip in Vue

Table of contents need Workaround 1. Set tooltip ...

Method for realizing Internet interconnection by VMware virtual machine bridging

After installing VMware and creating a new virtua...

Vue uses ECharts to implement line charts and pie charts

When developing a backend management project, it ...

Linux uses if to determine whether a directory exists.

How to use if in Linux to determine whether a dir...

How to access the local machine (host machine) in Docker

Question How to access the local database in Dock...

How to install and configure mysql 5.7.19 under centos6.5

The detailed steps for installing mysql5.7.19 on ...

Example code of layim integrating right-click menu in JavaScript

Table of contents 1. Effect Demonstration 2. Impl...

Solve the problem of MySql client exiting in seconds (my.ini not found)

Problem description (environment: windows7, MySql...

The difference between html empty link href="#" and href="javascript:void(0)"

# contains a location information. The default anc...

How to clean up the disk space occupied by Docker

Docker takes up a lot of space. Whenever we run c...

Using better-scroll component in Vue to realize horizontal scrolling function

About Recently, in the process of learning Vue, I...