Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Container Network

{ :no_toc }

Table of contents
  1. Container Network
    1. 1. Container Network structure
    2. 2. Port-Forwading
    3. 3. Adding Container network
    4. 4. Container to Container Networking

1. Container Network structure

  • Virtual ethernet bridge: 172.17.0.0/16.
  • It’s based on L2 Layer network.
  • The Veth interface is created when the container is created.
  • IP within bridge networks are sequential assign while the container running(these will be changed when the container restart).
  • The veth interface is created for inside connecting between the ‘docker0’bridge and the container. Also, it connects with ‘eht0’ in the container.
  • ‘docker0’ bonded with the veth interface roled to connect with the eth0 of the host.
    3 4 5

2. Port-Forwading

  • It is allowed to connect outside by exposing the container port to out.
    1
  • Port exposes through Ipables rule(automatic)
    1. -p <HostPort:ContainerPort>
    2
    2. -p <ContainerPort> (Hostport is appointed by random, it can check as ‘docker ps’)
    6 3. -P (Specifying the EXPOSE and Random host port specified in the dockerfile, It can check as ‘docker ps’)
    7

3. Adding Container network

  • The interface network in ‘docker0’ is not allowed to static mode. 8
    9

  • It is possible to create a user-defined bridge network like docker0. for connecting between eth0 interface in the host and veth interface in the container. 10 11
    12

    • –driver: You can select network type(bridge, ipvlan, mcvlan, overlay)
      13

    • –subnet: You can designate network range(If you skip it, It’ll be applied sequentially from 192.168.100.0)

    • –gateway: You can designate gateway IP(If you skip it, It’ll be applied x.x.x.1 )

    • mynet: You can create network name you want.

    • –net: You can designate network that container can using.(If you skip it, It’ll be ‘docker0’)

    • –ip: You can designate IP that the container can have. (If you skip it, It’ll be applied sequentially from x.x.x.1)

4. Container to Container Networking

  • Server & Client service operating by using container
  • Sending data whithin appear in container(wordpress) at front area to container(mysql)
    14 15
    • –link: Container connecting setting in same host network
    • –link <container name>:<hosts registered name>
    • When the link’s set up, container information will be registred to ‘hosts’ file automatically.
    • If Container’s registered IP is changed, hosts information will be modified automatically.

Table of contents