Docker-2:network containers
docker run -d -P --name web training/webapp python app.py # -name means give the to-be-run container a name 'web'. -P means connect web to default network space bridge
docker network ls
docker run -itd --name=networktest ubuntu #container named networktest from image ubuntu has defaultly connected to bridge
docker network inspect bridge
docker network create -d bridge my-bridge-network #create a new network space "my-bridge-network" with network type "bridge", the other type is "overlay".
docker network ls
docker network inspect my-bridge-network
docker run -d --network=my-bridge-network --name db training/webapp #run container "db" and add it to my-bridge-network
docker inspect my-bridge-network
docker inspect --format='{{json .NetworkSettings.Networks}}' db # check the networking of container db
docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' db # check the networking of container db
docker run -d -P --name web training/webapp python app.py # start a container web in net space "bridge"
docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' web # check the networking of container web
docker exec -it db bash #run container db with bash cmd #in the container, we use ping ip_of_web, it fails for web is in bridge while db is in my-bridge-network, eventhough both web and db containers are from the SAME image
docker network connect my-bridge-network web #now connect web to my-bridge-network,Docker networking allows you to attach a container to as many networks as you like.
docker exec -it db bash #run container db with bash cmd, use ping web. succeed cause web and db are in the same network
Docker-2:network containers的更多相关文章
- (转)Docker - 创建 Docker overlay network (containers 通信)
原文链接: http://www.cnblogs.com/AlanWalkOn/p/6101875.html --- 创建基于Key-Value的Docker overlay network. 这样运 ...
- Docker Network containers
Network containers Estimated reading time: 5 minutes If you are working your way through the user gu ...
- 【Network】Calico, Flannel, Weave and Docker Overlay Network 各种网络模型之间的区别
From the previous posts, I have analysed 4 different Docker multi-host network solutions - Calico, F ...
- Docker container network configuration
http://xmodulo.com/networking-between-docker-containers.html How to set up networking between Docker ...
- docker - 关于network的一些理解
docker 提供给我们多种(4种)网络模式,我们可以根据自己的需求来使用.例如我们在一台主机(host)或者同一个docker engine上面运行continer的时候,我们就可以选择bridge ...
- Docker6之Network containers
how to network your containers. Launch a container on the default network Docker includes support fo ...
- [Docker] Running Multiple Containers for an Angular, Node project
The code is from Plusight course, github link is here. In this post, we will give a overview about h ...
- docker 解决network has active endpoints
解决方式 使用 docker network disconnect -f {network} {endpoint-name},其中的 {endpoint-name} 可以使用命令 docker net ...
- ASP.NET Core 2.0 in Docker on Windows Containers
安装Docker for Windows https://store.docker.com/editions/community/docker-ce-desktop-windows 要想将一个ASP. ...
随机推荐
- zt:synpify 综合,保持信号,时序处理
http://www.actel.com/kb/article.aspx?id=TT1002 Logic Replication vs. Preserve Attributes in Synplici ...
- oracle 触发器学习
触发器使用教程和命名规范 目 录触发器使用教程和命名规范 11,触发器简介 12,触发器示例 23,触发器语法和功能 34,例一:行级触发器之一 45,例二:行级触发器之二 46,例三:INSTEA ...
- Win8.1无法安装.NET Framework 3.5的解决办法
这个问题纠结了我很多天,恢复系统也没用,差点儿就重装Win8,现在终于解决了,你也来试试吧! 机型:台电X89 系统:Win8.1 with bing 故障:在未安装.NET Framework 3. ...
- 【Shell脚本】怎样表示一个for循环
[Shell脚本]怎样表示一个for循环 在此说一下我常用的两个结构: 1. for i in $(seq 1 100); do echo $i done 2. for (( i = ...
- mysql实用操作
1.查看某个表的建表语句 show create table thetable -- thetable为待查表名
- 考查SQLite 3索引对整数排序的性能影响
做个实验,想了解SQLite3索引对整数排序的性能影响. 用这个测试表,考查绿色那列: id name date 自增型主键 字符串型,随机生成 整数型 随机生成,范围0到54354354 1 bMz ...
- js判断input输入框长度(支持中英文输入)
function CheckTxtLength(txt) { var num = txt.replace(/[^\x00-\xff]/g, 'xx').length; if (num <=11) ...
- 史航416第八次作业&总结
一.知识点总结: 1.数组的输入,输出及对整个数组所有元素进行操作通常都用循环结构实现. 2.可以只给部分元素赋初值.当{ }中值的个数少于元素个数时,只给前面部分元素赋值. 3.只能给元素逐个赋值, ...
- 注解式开发spring定时器
1:spring 配置文件中增加这句 <task:annotation-driven/> 2:确保扫描程序能够扫描后 下面第3步骤的java类 <context:co ...
- spring 自动扫描、注册的类是否可以定义构造函数
答案是肯定的. 方法如下: @Service public class SimpleMovieLister { private MovieFinder movieFinder; @Autowired ...