标签:href spec ref com one http run .com instead
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.
[Docker] Driver Bridge network for linking containers
标签:href spec ref com one http run .com instead
原文地址:https://www.cnblogs.com/Answer1215/p/10659062.html