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. ...
随机推荐
- python字符串及其方法详解
首先来一段字符串的基本操作 str1="my little pony" str2="friendship is magic" str3=str1+", ...
- php中的可变函数和匿名函数
可变函数 一个函数的名,是一个变量的时候,就称为可变函数 <?php header("content-type:text/html;charset=utf8"); funct ...
- Python-类变量,成员变量,静态变量,类方法,静态方法,实例方法,普通函数
#coding:utf-8class class_name(object): class_var = 'I am a class variable' #类变量 def __init__(self): ...
- Generate transparent shape on image
Here is an example code to generate transparent shape on image. Need to pay attention can not use cv ...
- 10个顶级的CSS UI开源框架
随着CSS3和HTML5的流行,我们的WEB页面不仅需要更人性化的设计理念,而且需要更酷的页面特效和用户体验.作为开发者,我们需要了解一些宝贵的CSS UI开源框架资源,它们可以帮助我们更快更好地实现 ...
- C# winform 动态调用WebService
封装的通用方法: using System; using System.Collections.Generic; using System.Text; using System.Xml; using ...
- android 简单打jar包
先建议一个moduel,先写一个下载图片代码: public class LoadTest extends AsyncTask<Void,Void,byte[]>{ public stat ...
- jQuery中的end()
要说end(),我们就不得不说prevObject. 在jQuery中,每个jQuery对象都有一个prevObject属性 var $p = $('p'); 这个属性是做什么的呢? jQuery内部 ...
- HTTP权威协议笔记-5.Web服务器
5.1 Web服务器工作内容 建立连接--接受一个客户端的连接,或者将其拒绝 接受请求--从网络中读取一条HTTP报文 处理请求--对请求报文进行解释,并采取行动 访问资源--访问报文中指定的资源 构 ...
- try--catch--finally中return返回值执行的顺序(区别)
1.try块中没有抛出异常,try.catch和finally块中都有return语句 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 public static int ...