Container network interconnection

Last Updated: Dec 18, 2017

Container Service creates the global network for containers, and the containers in the cluster can access other containers by using the eth0 network interface of the container.

For example, create containers on two machines respectively and record the container IP addresses. Log on to the container web terminal and test the network communication across nodes for these two containers by using the ping command.

  1. network-test1:
  2. image: busybox
  3. command: sh -c 'ifconfig eth0; sleep 100000'
  4. tty: true
  5. environment:
  6. - 'constraint:aliyun.node_index==1'
  7. network-test2:
  8. image: busybox
  9. command: sh -c 'ifconfig eth0; sleep 100000'
  10. tty: true
  11. environment:
  12. - 'constraint:aliyun.node_index==2'

The containers of these two services are distributed in different nodes.

1

By using the Container Service console or the ifconfig eth0 log output by container network-test1, you can see the IP address of container network-test1 is 172.18.1.4. Then, you can connect to the web terminal to access the IP address of container network-test1 in container network-test2 to test whether the network communication works.

Enter sh in the shell field and then click Execute. Then, enter the ping 172.18.1.4 command.

1

Thank you! We've received your feedback.