[Docker] Driver Bridge network for linking containers

In previous post we have seen how to link two container together by using `--link`:

# docker run -d --name my-mongodb mongo
# docker run -d -p 3000:3000 --link my-mongodb:mongodb --name nodeapp danwahlin/node

 

In this poist, we are going to see how to create brige network, and link contianer inside network.

 

First, we can create a network:

docker network create --driver bridge isolated_network

 

We can inspect our network:

docker network inspect isolated_network

Once we add container into network, this command is helpful.

 

Run the MongoDB container and link it into network, also give it a name 'mongodb'

docker run -d --net=isolated_network --name mongodb mongo

 

Run the nodejs container and link it to network, also give it a name 'nodeapp':

docker run -d -p 3000:3000 --net=isolated_network --name nodeapp danwalin/node

 

Linking container into network is useful for tow or three containers, but once we have more containers, it is not convenient to write so many command lines to get job done. Instead we can use Docker Compose for this task.

 

posted @   Zhentiw  阅读(230)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
历史上的今天:
2018-04-05 [React Router] Prevent Navigation with the React Router Prompt Component
2018-04-05 [Web Worker] Introduce to Web Worker
2018-04-05 [React] Reference a node using createRef() in React 16.3
2017-04-05 [Javascript] Understand Function Composition By Building Compose and ComposeAll Utility Functions
2016-04-05 [Angular 2] @ViewChild to access Child component's method
点击右上角即可分享
微信分享提示