单机让多docker拥有多ip出口

1、创建docker 桥接网络

docker network create \

--driver bridge \

--subnet=172.30.20.0/24 \

--gateway=172.30.20.1 \

nginx-bridge-eth2

2、创建docker-nginx容器

docker run -d --name nginx-eth2-1 \

--network nginx-bridge-eth2 \

nginx

3、添加路由

echo "102 eth2-routing" >> /etc/iproute2/rt_tables

root@hwy-isms-nginx-0-30:/hskj# ip route add default via 192.168.0.1 dev eth2 table eth2-routing

root@hwy-isms-nginx-0-30:/hskj# ip rule add from 172.30.20.0/24 lookup eth2-routing

root@hwy-isms-nginx-0-30:/hskj# ip route flush cache

4、验证

docker exec -it 1676bce8da35 curl cip.cc

相关推荐
暮云星影5 小时前
个人总结 搭建Docker监控
docker·容器·grafana·prometheus
维度攻城狮7 小时前
在Vscode连接的Docker容器中使用codex,并配置DeepSeek模型
vscode·docker·codex
l1t10 小时前
DeepSeek总结的使用 Docker 对 PostgreSQL 进行 Beta 测试
docker·postgresql·容器
暮云星影15 小时前
个人总结 docker 常用命令
docker·容器
极客先躯16 小时前
高级java每日一道面试题-2026年01月19日-实战篇[Docker]-如何配置镜像仓库的垃圾回收 (GC)?
java·运维·docker·容器
日取其半万世不竭17 小时前
low-memory-server-swap-20260601
docker·容器·https
暮云星影17 小时前
个人总结 docker搭建PDF操作工具
docker·容器·pdf
zhoupenghui16817 小时前
AI大模型应用部署之Flask框架使用
运维·python·docker·容器·flask·flask框架
kishu_iOS&AI18 小时前
Mac —— Docker Desktop(Milvus和Redis)部署
redis·docker·milvus
花花少年19 小时前
基于Docker快速部署OneAPI以及统一调用国产大模型
docker·oneapi·deepseek