Debian 11.2にDocker コンテナーのネットワークを指定する
環境
osバージョンを確認します
# cat /etc/debian_version
11.2
操作方法
1.ネットワーク一覧を表示します
# docker network ls NETWORK ID NAME DRIVER SCOPE 70d4405e70a1 bridge bridge local c1453dfa9bad host host local f72041416ff8 none null local
2.「bridge」の詳細を表示します
# docker network inspect bridge [ { "Name": "bridge", "Id": "70d4405e70a18373af9b2964e3eb9c308a8b5f0d88a3ad69af6e8c2867e3ca20", "Created": "2021-12-27T19:32:12.709510262-05:00", "Scope": "local", "Driver": "bridge", "EnableIPv6": false, "IPAM": { "Driver": "default", "Options": null, "Config": [ { "Subnet": "172.17.0.0/16", "Gateway": "172.17.0.1" } ] }, "Internal": false, "Attachable": false, "Ingress": false, "ConfigFrom": { "Network": "" }, "ConfigOnly": false, "Containers": {}, "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": {} } ]
3.コンテナーのネットワークは[bridge]を使用する
# docker run debian /bin/bash -c "apt-get update; apt-get -y install iproute2; ip route" 略 default via 172.17.0.1 dev eth0 172.17.0.0/16 dev eth0 proto kernel scope link src 172.17.0.2