修改docker默认网关

docker启动后,会默认生成一个docker0网关,子网地址是”Subnet”: “172.17.0.0/16″。

使用命令查看docker默认网关

1)查看docker网络

docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
b510dab72a56        bridge              bridge              local
d5df2e731503        host                host                local
8b529a02ba63        none                null                local

2)查看docker默认网关

# docker network inspect b510dab72a56
[
    {
        “Name”: “bridge”,
        “Id”: “b510dab72a566c60789295b17ed0a8fe22cbad38a42cfe12d3e5145c08b8b73f”,
        “Created”: “2022-03-10T01:50:58.52659914+08:00”,
        “Scope”: “local”,
        “Driver”: “bridge”,
        “EnableIPv6”: false,
        “IPAM”: {
            “Driver”: “default”,
            “Options”: null,
            “Config”: [
                {
                    “Subnet”: “172.17.0.0/16”,
                    “Gateway”: “172.17.0.1”

                }
            ]
        },

3. 修改docker默认网关

如下添加一行 “bip”:”172.31.0.1/16″

vim /etc/docker/daemon.json

{

"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"] ,

"bip":"172.31.0.1/16"

}

4. 重启docker生效

systemctl daemon-reload
systemctl restart docker

    原文作者:架构艺术AA
    原文地址: https://blog.csdn.net/LG_15011399296/article/details/123568511
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞