Cross-host container network

Last Updated: Nov 14, 2016

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

For example, create the container respectively on two machines and print their IP addresses.

  1. cross-host-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. cross-host-network-test2:
  8. image: busybox
  9. command: sh -c 'ifconfig eth0; sleep 100000'
  10. tty: true
  11. environment:
  12. - 'constraint:aliyun.node_index==(2)'

You can see that the containers of these two services are distributed in different nodes.

servicelist

Using the ifconfig eth0 log output from the console or container 2, you can see that the IP address of container 2 is 172.19.0.10. Then, you can connect to a remote terminal to access the IP address of Container 2 from Container 1.

pingtest

Thank you! We've received your feedback.