阅读921 返回首页    go iPhone_iPad_Mac_apple


跨主机互联的容器网络__网络管理_用户指南_容器服务-阿里云

容器服务为容器创建全局的网络,集群中的容器都可以通过容器的 eth0 的网络接口访问其它容器。

例如:分别在两台机器上创建容器,并打印出它们的 IP 地址。

  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)'

可以看到这两个服务的容器分布在不同的节点上,如下图所示。

通过容器服务管理控制台或者通过容器 2 输出的ifconfig eth0日志,您可以看到容器 2 的 IP 地址为172.19.0.10。您可以通过连接远程终端在容器 1 内访问容器 2 的 IP 地址。如下图所示。

最后更新:2016-11-23 16:56:29

  上一篇:go 删除服务__服务管理_用户指南_容器服务-阿里云
  下一篇:go 开通数据卷功能__数据卷指南_用户指南_容器服务-阿里云