Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Modify the docker default bridge

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Here are two ways to modify the docker default bridge, both of which are achieved by modifying the daemon.json file.

First kind

1. Delete the old network

$sudo service docker stop

$sudo ip link set dev docker0 down

$sudo brctl delbr docker0

2. Modify / etc/docker/daemon.json file

Vim / etc/docker/daemon.json

{

"bip": "192.168.0.1 Compact 24"

}

3. Restart the Doker service

$sudo service docker start

4. Check

$ifconfig docker0

Docker0: flags=4163 mtu 1500

Inet 192.168.0.1 netmask 255.255.255.0 broadcast 192.168.0.255

Inet6 fe80::42:43ff:fe3d:4565 prefixlen 64 scopeid 0x20

Ether 02:42:43:3d:45:65 txqueuelen 0 (Ethernet)

RX packets 0 bytes 0 (0.0B)

RX errors 0 dropped 0 overruns 0 frame 0

TX packets 7 bytes 586 (586.0 B)

TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

5. Create a new container and view the ip

Docker run-it mysql / bin/bash

Then press Ctrl+D to push the container to check the container status docker ps-a

At this point, we check that the ip of the container is null, because the container does not have ip information in the exit state.

Let's check it out.

Docker inspect e5

Open the container

Docker start e5

Check again

Docker inspect e5

The second kind

1. Delete the old bridge

$sudo service docker stop

$sudo ip link set dev docker0 down

$sudo brctl delbr docker0

2. Manually create a new bridge named bridge0

$sudo brctl addbr bridge0

$sudo ip addr add 192.188.0.1 Compact 16 dev bridge0

$sudo ip link set dev bridge0 up

3. Check whether a bridge0 has been created

Ifconfig beidge0

Bridge0: flags=4163 mtu 1500

Inet 192.168.0.1 netmask 255.255.255.0 broadcast 0.0.0.0

Inet6 fe80::9044:aeff:fed1:155f prefixlen 64 scopeid 0x20

Ether 7e:5f:08:47:cf:48 txqueuelen 1000 (Ethernet)

RX packets 0 bytes 0 (0.0B)

RX errors 0 dropped 0 overruns 0 frame 0

TX packets 8 bytes 656 (656.0 B)

TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

4. Create dameon.json

Vim / etc/docker/dameon.json

{

"bridge": "beidge0"

}

5. Restart docker

Service docker start

Create a new container and view the ip as in step 5 of the first method!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report