Docker Networking Overview

Overview

Estimated reading time:?4 minutes

One of the reasons Docker containers and services are so powerful is that you can connect them together, or connect them to non-Docker workloads. Docker containers and services do not even need to be aware that they are deployed on Docker, or whether their peers are also Docker workloads or not. Whether your Docker hosts run Linux, Windows, or a mix of the two, you can use Docker to manage them in a platform-agnostic way.

This topic defines some basic Docker networking concepts and prepares you to design and deploy your applications to take full advantage of these capabilities.

Most of this content applies to all Docker installations. However,?a few advanced features?are only available to Docker EE customers.

Scope of this topic

This topic does?not?go into OS-specific details about how Docker networks work, so you will not find information about how Docker manipulates?iptables?rules on Linux or how it manipulates routing rules on Windows servers, and you will not find detailed information about how Docker forms and encapsulates packets or handles encryption. See?Docker and iptables?and?Docker Reference Architecture: Designing Scalable, Portable Docker Container Networks?for a much greater depth of technical detail.

In addition, this topic does not provide any tutorials for how to create, manage, and use Docker networks. Each section includes links to relevant tutorials and command references.

Network drivers

Docker’s networking subsystem is pluggable, using drivers. Several drivers exist by default, and provide core networking functionality:

bridge: The default network driver. If you don’t specify a driver, this is the type of network you are creating.?Bridge networks are usually used when your applications run in standalone containers that need to communicate.?See?bridge networks.

host: For standalone containers, remove network isolation between the container and the Docker host, and use the host’s networking directly.?host?is only available for swarm services on Docker 17.06 and higher. See?use the host network.

overlay: Overlay networks connect multiple Docker daemons together and enable swarm services to communicate with each other. You can also use overlay networks to facilitate communication between a swarm service and a standalone container, or between two standalone containers on different Docker daemons. This strategy removes the need to do OS-level routing between these containers. See?overlay networks.

macvlan: Macvlan networks allow you to assign a MAC address to a container, making it appear as a physical device on your network. The Docker daemon routes traffic to containers by their MAC addresses. Using the?macvlan?driver is sometimes the best choice when dealing with legacy applications that expect to be directly connected to the physical network, rather than routed through the Docker host’s network stack. See?Macvlan networks.

none: For this container, disable all networking. Usually used in conjunction with a custom network driver.?none?is not available for swarm services. See?disable container networking.

Network plugins: You can install and use third-party network plugins with Docker. These plugins are available from?Docker Store?or from third-party vendors. See the vendor’s documentation for installing and using a given network plugin.

Network driver summary

User-defined bridge networks?are best when you need multiple containers to communicate on the same Docker host.

Host networks?are best when the network stack should not be isolated from the Docker host, but you want other aspects of the container to be isolated.

Overlay networks?are best when you need containers running on different Docker hosts to communicate, or when multiple applications work together using swarm services.

Macvlan networks?are best when you are migrating from a VM setup or need your containers to look like physical hosts on your network, each with a unique MAC address.

Third-party network plugins?allow you to integrate Docker with specialized network stacks.

?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
  • 序言:七十年代末缅疟,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子遍愿,更是在濱河造成了極大的恐慌存淫,老刑警劉巖,帶你破解...
    沈念sama閱讀 217,406評論 6 503
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件沼填,死亡現(xiàn)場離奇詭異桅咆,居然都是意外死亡,警方通過查閱死者的電腦和手機坞笙,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,732評論 3 393
  • 文/潘曉璐 我一進店門岩饼,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人薛夜,你說我怎么就攤上這事籍茧。” “怎么了梯澜?”我有些...
    開封第一講書人閱讀 163,711評論 0 353
  • 文/不壞的土叔 我叫張陵寞冯,是天一觀的道長。 經常有香客問我晚伙,道長吮龄,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,380評論 1 293
  • 正文 為了忘掉前任咆疗,我火速辦了婚禮螟蝙,結果婚禮上,老公的妹妹穿的比我還像新娘民傻。我一直安慰自己,他們只是感情好场斑,可當我...
    茶點故事閱讀 67,432評論 6 392
  • 文/花漫 我一把揭開白布漓踢。 她就那樣靜靜地躺著,像睡著了一般漏隐。 火紅的嫁衣襯著肌膚如雪喧半。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,301評論 1 301
  • 那天青责,我揣著相機與錄音挺据,去河邊找鬼取具。 笑死,一個胖子當著我的面吹牛扁耐,可吹牛的內容都是我干的暇检。 我是一名探鬼主播,決...
    沈念sama閱讀 40,145評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼婉称,長吁一口氣:“原來是場噩夢啊……” “哼块仆!你這毒婦竟也來了?” 一聲冷哼從身側響起王暗,我...
    開封第一講書人閱讀 39,008評論 0 276
  • 序言:老撾萬榮一對情侶失蹤悔据,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后俗壹,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體科汗,經...
    沈念sama閱讀 45,443評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 37,649評論 3 334
  • 正文 我和宋清朗相戀三年绷雏,在試婚紗的時候發(fā)現(xiàn)自己被綠了头滔。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 39,795評論 1 347
  • 序言:一個原本活蹦亂跳的男人離奇死亡之众,死狀恐怖拙毫,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情棺禾,我是刑警寧澤缀蹄,帶...
    沈念sama閱讀 35,501評論 5 345
  • 正文 年R本政府宣布,位于F島的核電站膘婶,受9級特大地震影響缺前,放射性物質發(fā)生泄漏。R本人自食惡果不足惜悬襟,卻給世界環(huán)境...
    茶點故事閱讀 41,119評論 3 328
  • 文/蒙蒙 一衅码、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧脊岳,春花似錦逝段、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,731評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至亿驾,卻和暖如春嘹黔,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背莫瞬。 一陣腳步聲響...
    開封第一講書人閱讀 32,865評論 1 269
  • 我被黑心中介騙來泰國打工儡蔓, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留郭蕉,地道東北人。 一個月前我還...
    沈念sama閱讀 47,899評論 2 370
  • 正文 我出身青樓喂江,卻偏偏與公主長得像召锈,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子开呐,可洞房花燭夜當晚...
    茶點故事閱讀 44,724評論 2 354

推薦閱讀更多精彩內容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi閱讀 7,325評論 0 10
  • PLEASE READ THE FOLLOWING APPLE DEVELOPER PROGRAM LICENSE...
    念念不忘的閱讀 13,471評論 5 6
  • 昨晚睡的很遲烟勋,后來又做了好多惡夢,夢見死了人筐付,可能是因為這部電影吧卵惦。反反復復地處于半睡眠狀態(tài),折騰了一宿瓦戚。 有時候...
    故人從來與風閱讀 282評論 0 1
  • 《斷舍離》這本書我已經聽過兩遍音頻沮尿、看過一遍紙書了,這本書給我?guī)淼母淖儾谎远鳌?透過對物品的取舍反映出自己內心...
    樂簡家閱讀 307評論 0 2
  • 其實這次能拿到最佳较解,我是很意外的畜疾,因為我寫的感悟其實是在質疑晨讀文章里的說法。由此可見印衔,班委們評選的眼光是很客觀開...
    白菜花君閱讀 290評論 2 5