出现该问题是因为只有使用–subnet创建的网络才能指定静态IP
如下使用–subnet创建网络(用来指定ip段),–gateway(用来指定网关),my_net3为创建的名字
docker network create --driver bridge --subnet 172.22.1.0/24 --gateway 172.22.1.1 my_net
————————————————
版权声明:本文为CSDN博主「艾维巴蒂」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_41634738/article/details/105113259
version: "3.9"
services:
test:
container_name: test
image: registry.cn-hangzhou.aliyuncs.com/lwmacct/ubuntu:v20.04-t2022020101
restart: always
networks:
default:
ipv4_address: 172.22.1.100
command:
- 'tail'
- '-f'
- '/dev/null'
volumes:
- "/proc:/host"
- "/data/kuaicdn/network/netns-v2.x-ctrl/link/public:/apps/public/"
- "/data/kuaicdn/network/netns-v2.x-ctrl/link/882dbe9d0344:/apps/data/"
environment:
MAC: "88:2d:be:9d:03:44"
VLAN: "0"
IP_MASK: "192.168.1.101/24"
GATEWAY: "192.168.1.1"
BRIDGE: "br-ikuai-lan1"
MAX_TX: "2000"
MAX_RX: "2000"
ENABLE: "1"
networks:
default:
external:
name: my_net