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的更多相关文章

  1. (转)Docker - 创建 Docker overlay network (containers 通信)

    原文链接: http://www.cnblogs.com/AlanWalkOn/p/6101875.html --- 创建基于Key-Value的Docker overlay network. 这样运 ...

  2. Docker Network containers

    Network containers Estimated reading time: 5 minutes If you are working your way through the user gu ...

  3. 【Network】Calico, Flannel, Weave and Docker Overlay Network 各种网络模型之间的区别

    From the previous posts, I have analysed 4 different Docker multi-host network solutions - Calico, F ...

  4. Docker container network configuration

    http://xmodulo.com/networking-between-docker-containers.html How to set up networking between Docker ...

  5. docker - 关于network的一些理解

    docker 提供给我们多种(4种)网络模式,我们可以根据自己的需求来使用.例如我们在一台主机(host)或者同一个docker engine上面运行continer的时候,我们就可以选择bridge ...

  6. Docker6之Network containers

    how to network your containers. Launch a container on the default network Docker includes support fo ...

  7. [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 ...

  8. docker 解决network has active endpoints

    解决方式 使用 docker network disconnect -f {network} {endpoint-name},其中的 {endpoint-name} 可以使用命令 docker net ...

  9. ASP.NET Core 2.0 in Docker on Windows Containers

    安装Docker for Windows https://store.docker.com/editions/community/docker-ce-desktop-windows 要想将一个ASP. ...

随机推荐

  1. 多态与异常处理ppt作业

    1.请阅读并运行AboutException.java示例,然后通过后面的几页PPT了解Java中实现异常处理的基础知识. 答:1.抛出异常 当程序发生异常时,产生一个异常事件,生成一个异常对象,并把 ...

  2. MySQL效能监控工具mysqlreport安装和中文说明

    管理 mysql 最让人困扰的就是如何有效的掌握 MySQL 的健康状况,因为 MySQL 虽然有提供许多系统变量值供您参考,但这些零散的数据若要手动搜集与过滤将会是一件十分没有效率的事情(除非您写 ...

  3. centos6升级python2.7

    #下载python #wget http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2 #安装支持https yum install opens ...

  4. [JSP]用户注册

    //----------------------userRegister.jsp <%@ page contentType="text/html;charset=gb2312" ...

  5. .NET 配置项扩展

    using System; using System.Configuration; namespace ConsoleApplication3 { /* web.config 或 app.config ...

  6. windows server 无人值守安装

    使用 answer file:AutoUnattend.xml 来无人值守安装,到了选系统这步 还是要手动选择一个系统,这是为什么?怎么设置可以默认进入GUI的系统进行安装啊?

  7. 查看表的datapages

    select object_name(i.object_id) as tableName,data_pages as dataPagesfrom sys.indexes as ijoin sys.pa ...

  8. Quartus II中的Waring(转)

    1.Found clock-sensitive change during active clock edge at time <time> on register "<n ...

  9. 仿东软OA协同办公服务管理系统

    兼容IE6,7,8以上.GooleChrome.360及遨游等浏览器.系统特色:1.系统经过抗压测试.2.语音提示功能.3.支持office2007在线编辑.4.强大的图形化工作流程设计及文档编辑留痕 ...

  10. Magento1.9批量修改产品 Attribute Set

    今天修改产品时遇到这样一个需求:重新设置产品的 Attribute Set,使用的是Magento1.9系统,Magento提供这样一个插件 Flagbit Change Attribute Set: ...