bridge模式,使用- -net=bridge指定,默认设置。
$ docker network ls NETWORK ID NAME DRIVER 7fca4eb8c647 bridge bridge 9f904ee27bf5 none null cf03ee007fb4 host host这三个网络都建在Docker中。运行容器时,可以使用该--network标志来指定容器应连接到的网络。
# 堆代码 duidaima.com [root@iZ2ze74fkxrls31tr2ia2fZ ~]# docker network inspect bridge [ { "Name": "bridge", "Id": "7436e01fb532a9b25318c3d14c22a2b8bbf67fe9a1c4034d8529c17b98ce3408", "Scope": "local", "Driver": "bridge", "EnableIPv6": false, "IPAM": { "Driver": "default", "Options": null, "Config": [ { "Subnet": "192.168.1.1/24", "Gateway": "192.168.1.1" } ] }, "Internal": false, "Containers": { "ac36d9ff3cad1233ff52a46f413b8f5442c6d73470aca27c25c2296f72bcca0d": { "Name": "centos-java", "EndpointID": "62f4d3245b96dd5ff8da0fd5801388664d118b693bf5e0db72209b9335734269", "MacAddress": "02:42:c0:a8:01:03", "IPv4Address": "192.168.1.3/24", "IPv6Address": "" }, "b5a21b26c111eb2b4c6a0823dd3c861de0e07fe485b51135cbf5c29318269810": { "Name": "centos", "EndpointID": "1719493bcaaec67568f5a39c1afc641c5dc6e7a65ea3733ad40c21f1b45c8ca4", "MacAddress": "02:42:c0:a8:01:02", "IPv4Address": "192.168.1.2/24", "IPv6Address": "" } }, "Options": { "com.docker.network.bridge.default_bridge": "true", "com.docker.network.bridge.enable_icc": "true", "com.docker.network.bridge.enable_ip_masquerade": "true", "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0", "com.docker.network.bridge.name": "docker0", "com.docker.network.driver.mtu": "1500" }, "Labels": {} } ]修改网段
{ "bip": "192.168.1.1/24" }重启 docker 服务:
systemctl restart docker查看修改后的 docker0 网桥信息:
ifconfig docker0有关daemon.json文件参数,这是Linux上允许的配置选项的完整示例:
{ "authorization-plugins": [], "data-root": "", "dns": [], "dns-opts": [], "dns-search": [], "exec-opts": [], "exec-root": "", "experimental": false, "storage-driver": "", "storage-opts": [], "labels": [], "live-restore": true, "log-driver": "", "log-opts": {}, "mtu": 0, "pidfile": "", "cluster-store": "", "cluster-store-opts": {}, "cluster-advertise": "", "max-concurrent-downloads": 3, "max-concurrent-uploads": 5, "default-shm-size": "64M", "shutdown-timeout": 15, "debug": true, "hosts": [], "log-level": "", "tls": true, "tlsverify": true, "tlscacert": "", "tlscert": "", "tlskey": "", "swarm-default-advertise-addr": "", "api-cors-header": "", "selinux-enabled": false, "userns-remap": "", "group": "", "cgroup-parent": "", "default-ulimits": {}, "init": false, "init-path": "/usr/libexec/docker-init", "ipv6": false, "iptables": false, "ip-forward": false, "ip-masq": false, "userland-proxy": false, "userland-proxy-path": "/usr/libexec/docker-proxy", "ip": "0.0.0.0", "bridge": "", "bip": "", "fixed-cidr": "", "fixed-cidr-v6": "", "default-gateway": "", "default-gateway-v6": "", "icc": false, "raw-logs": false, "allow-nondistributable-artifacts": [], "registry-mirrors": [], "seccomp-profile": "", "insecure-registries": [], "no-new-privileges": false, "default-runtime": "runc", "oom-score-adjust": -500, "node-generic-resources": ["NVIDIA-GPU=UUID1", "NVIDIA-GPU=UUID2"], "runtimes": { "cc-runtime": { "path": "/usr/bin/cc-runtime" }, "custom": { "path": "/usr/local/bin/my-runc-replacement", "runtimeArgs": [ "--debug" ] } } }