Dockerã®ãããã¯ã¼ã¯æ§æã«ã¤ãã¦æ´çããã
å³1: Dockerãããã¯ã¼ã¯å ¨ä½å³
ç©çNICã1åã¤ããDockerãã¹ãã«2ã¤ã®ã³ã³ãããç«ã¦ãã¨ãå³1ã®ããã«ãªããã³ã³ããã¯172.17.X.Xã®ãããã¯ã¼ã¯å ã«ãã¦ããã¹ãå´ã«ã¯172.17.0.1ã®IPã¢ãã¬ã¹ãä»ãããã®æ§æèªä½ã¯ãVirtualBoxã§è¨ãã¨ããã®ãã¹ããªã³ãªã¼ãããã¯ã¼ã¯ã¨åããããªãã®ãç°ãªãç¹ã¨ãã¦ãDockerãããã¯ã¼ã¯ã¯ããã¼ãã¦ã§ã¢ä»®æ³åã§ã¯ãªããLinuxã«ã¼ãã«ã®æ©è½ã§ããvethãã¢ã¨ããªãã¸ãçµã¿åããã¦å®ç¾ãããã
å³2: vethãã¢
veth (virtual Ethernet) ã¯ãå³2ã®ããã«ãä»®æ³NICã®ãã¢ã¨ããããã¤ãªãä»®æ³ã±ã¼ãã«ãä½ãæ©è½ããµãã¤ã®ä»®æ³NICã¯ã¤ã¼ãµãããã§ç´æ¥éä¿¡ã§ããã
å³3: ããªãã¸
ããªãã¸ã¨ã¯ãLinuxãã·ã³ãL2ã¹ã¤ããï¼ã¹ã¤ããã³ã°ããï¼ã¨ãã¦åä½ããããã«æ§æããæ©è½ãå³3ã®ããã«ãããªãã¸ã«ç´ä»ããããNICã¯ä»®æ³L2ã¹ã¤ããã®ãã¼ãã¨ãªããããããã®NICã«ã¤ãªãã£ããã¹ãå士ã¯ã¤ã¼ãµãããã§éä¿¡ã§ãããNICãããªãã¸ã«ç´ä»ããã¨ããã®MACã¢ãã¬ã¹ã使ã£ãã¤ã¼ãµãããéä¿¡ã¯ã§ããªããªããã¾ãIPã¢ãã¬ã¹ãå²ãå½ã¦ããã¨ãã§ããªããªãããã®ä»£ãããããªãã¸ã«å¯¾ãã¦MACãå²ãå½ã¦ãããã®ã§ãããªãã¸ãæ§æãããã¹ãï¼å³ä¸ã®Bridger Hostï¼ã¯ãããªãã¸ã®MACã使ã£ã¦ãåNICã®å¯¾åã«ãããã¹ãã¨ã¤ã¼ãµãããã§éä¿¡ã§ããã
Bridger Host / Other Host 1 / Other Host 2ã¯ãã¤ã¼ãµãããã§ç¸äºã«éä¿¡ã§ããã®ã§ãã²ã¨ã¤ã®ãããã¯ã¼ã¯ã»ã°ã¡ã³ããæ§æã§ããã
å³4: Dockerãããã¯ã¼ã¯å ¨ä½å³ï¼è©³ç´°ï¼
å度å
¨ä½å³ã«æ»ãã¨ï¼å³4ï¼ãDockerãã¹ãå
ã«ã¯ã²ã¨ã¤ã®ããªãã¸ãæ§æããã¦ããã®MACã«IPã¢ãã¬ã¹172.17.0.1ãå²ãå½ã¦ããããã¾ããã³ã³ãããã¨ã«1ã¤ã®vethãã¢ãæ§æããã¦ãçæ¹ã®ä»®æ³NICã¯ããªãã¸ã«ç´ä»ãããããããçæ¹ã®ä»®æ³NICã«ã¯172.17.X.Xã®IPã¢ãã¬ã¹ãå²ãå½ã¦ããã¦ãã³ã³ããã«æå±ãããããããçæ¹ã®ä»®æ³NICã¯ã³ã³ããã«æå±ããããã¦ã172.17.X.Xã®IPã¢ãã¬ã¹ãå²ãå½ã¦ããã *1ãvethãã¢ã¯ç¸äºã«éä¿¡ã§ãããã¹ãå´ã®ä»®æ³NICã¯ããªãã¸ã«ã¤ãªãã£ã¦ããã®ã§ãããªãã¸ãéãã¦ã³ã³ãã/ã³ã³ããéãã³ã³ãã/ãã¹ãéã®ã¤ã¼ãµãããéä¿¡ãã§ããããããã£ã¦ãããããã¾ã¨ãã¦ã²ã¨ã¤ã®ãããã¯ã¼ã¯ã»ã°ã¡ã³ãã¨ã§ããã
ãã¹ãå´ã§ifconfigã³ãã³ããæ®éã«å®è¡ãã¦ããã³ã³ããã«æå±ããä»®æ³NICã¯è¦ããªããã¾ãããã¹ãå´ã®ããã»ã¹ããã®NICã«ç´ä»ããããIPã¢ãã¬ã¹ã使ã£ã¦éä¿¡ãããã¨ããæ®éã«ã¯ã§ããªããä¸æ¹ãã³ã³ããå ã®ããã»ã¹ããè¦ããã®ã¯ãã³ã³ããã«ç´ä»ããããä»®æ³NICã ãã§ããã¨ãã°ãã¹ãã®ç©çNICã¯è¦ããªããããã¯ãLinuxã®ãããã¯ã¼ã¯åå空éæ©è½ã«ãã£ã¦å®ç¾ããã¦ãããã³ã³ãããã¨ã«ãããã¯ã¼ã¯åå空éãã²ã¨ã¤ä½ãããåã³ã³ããå ã®ããã»ã¹ã¯ãã®åå空éä¸ã§å®è¡ããããä»®æ³NICã¯ããã¹ãå´ã®ããã©ã«ãã®åå空éããã³ã³ããã®åå空éã«ç§»åããããã¨ã«ãã£ã¦ãã³ã³ããã«æå±ããããã¹ãã®ã·ã§ã«ããã³ã³ããã«æå±ããNICãè¦ãããã«ã¯ãnetnsã³ãã³ããnsenterã³ãã³ãã§åå空éãåãæ¿ããã
ã«ã¼ãã£ã³ã°ãNAPTããã¼ããã©ã¯ã¼ãã£ã³ã°ã¯ãLinuxã«ã¼ãã«ã®ã«ã¼ãã£ã³ã°æ©è½ããã®ã¾ã¾ä½¿ããããã«ã¤ãã¦ã¯ãDockerç¹æã®è«ç¹ãä»®æ³åç¹æã®è«ç¹ããªãã¨æãã
åèæç®:
- ããªãã¸ã«ã¤ãã¦åºç¤çãªèª¬æ
- Linuxãã·ã³ãå®éã«ãããã¯ã¼ã¯ã¹ã¤ããã¨ãã¦ä½¿ã£ã話
- vethãã¢ï¼TUN, TAPã«ã¤ãã¦ãï¼
- ãããã¯ã¼ã¯åå空é
- Dockerã®ãããã¯ã¼ã¯æ§æ
- ãã¡ã¤ã«ã·ã¹ãã ä¸ã«åå¨ããªããããã¯ã¼ã¯åå空éã®ä¸ãã®ããæ¹æ³
*1:2017-01-28ã«ä¿®æ£ãIPã¢ãã¬ã¹ã®å²ãå½ã¦ã¯ã³ã³ããã®ãããã¯ã¼ã¯åå空éã§è¡ããããããå ã®è¨è¿°ã¯ä¸æ£ç¢ºã§ããã