简体   繁体   English

永久更改docker bridge IP

[英]permanently change docker bridge IP

I am trying to configure dockerd to use the bridge ip 172.31.0.1/24 (as i understand it must be a subnet). 我正在尝试将dockerd配置为使用网桥ip 172.31.0.1/24(据我所知它必须是子网)。 I configured the file /etc/docker/daemon.json as follows: 我将文件/etc/docker/daemon.json配置如下:

{   "dns": ["8.8.8.8", "8.8.4.4"]}
{  "bip": "172.31.1.1/24",
  "ipv6": false}

Then i did systemctl stop docker && systemctl start docker It didn't work :-/ Can you pls help me set up this bridge subnet permanently? 然后我让systemctl stop docker && systemctl start docker :-/您能帮我永久设置这个桥子网吗? Most help online is on temporary setting, not my interest. 在线上的大多数帮助只是暂时的,而不是我的兴趣。

I also changed the file /etc/default/docker , but it does not seem to make a difference on systems running on systemd. 我还更改了文件/etc/default/docker ,但是在systemd上运行的系统上似乎没有什么不同。

Ubuntu 16.04, Docker version 17.12.1-ce, build 7390fc6 Ubuntu 16.04,Docker版本17.12.1-CE,内部版本7390FC6

Your /etc/docker/daemon.json is not correct right now. 您的/etc/docker/daemon.json目前不正确。 Literally it contains two JSON structures inside: 从字面上看,它内部包含两个JSON结构:

{   "dns": ["8.8.8.8", "8.8.4.4"]}

and

{  "bip": "172.31.1.1/24",
  "ipv6": false}

When you start/restart docker on your host it reads JSON structure from /etc/docker/daemon.json ie only the first part of it. 当您在主机上启动/重新启动/etc/docker/daemon.json它会从/etc/docker/daemon.json读取JSON结构,即仅读取其中的第一部分。 That's why IP changes are not applied. 这就是为什么不应用IP更改的原因。

The correct /etc/docker/daemon.json is: 正确的/etc/docker/daemon.json是:

{ 
  "dns": ["8.8.8.8", "8.8.4.4"], 
  "bip": "172.30.1.1/24",
  "ipv6": false
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM