如何在主机之间连接Docker服务? [英] How to link Docker services across hosts?

查看:101
本文介绍了如何在主机之间连接Docker服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Docker 允许来自多个容器的服务器通过链接和服务发现相互连接。然而,从我可以看到这个服务发现是主机本地的。我想实现使用托管在其他机器上的其他服务的服务。

Docker allows servers from multiple containers to connect to each other via links and service discovery. However, from what I can see this service discovery is host-local. I would like to implement a service that uses other services hosted on a different machine.

在Docker中有几种方法来解决这个问题,例如 CoreOS的跳线 ,主机本地服务基本上代理到另一台机器,以及一大堆github项目管理Docker似乎试图支持这种用例的部署。

There have been several approaches to solving this problem in Docker, such as CoreOS's jumpers, host-local services that essentially proxy to the other machine, and a whole bunch of github projects for managing Docker deployments that appear to have attempted to support this use-case.

鉴于发展的步伐,很难遵循当前的最佳做法。因此,我的问题本质上是:1)什么(如果有的话)是目前在Docker中主机连接的主要方法,2)是否有任何计划直接在Docker系统中支持该功能?

Given the pace of development it is hard to follow what current best practices are. Therefore my question is essentially: 1) What (if any) is the current predominant method for linking across hosts in Docker, and 2) are there any plans for supporting this functionality directly in the Docker system?

推荐答案

更新

Docker最近宣布一个新的工具称为<对于Docker编排,href =https://docs.docker.com/swarm/ =nofollow noreferrer> Swarm

Docker has recently announced a new tool called Swarm for Docker orchestration.

Swarm 允许您加入多个Docker守护程序:您首先创建一个群集,在一台机器上启动一个群组管理器,并具有docker守护进程使用群组标识符加入群组管理员。码头服务器客户端连接到群组管理器,就像它是一个普通的docker服务器一样。

Swarm allows you do "join" multiple docker daemons: You first create a swarm, start a swarm manager on one machine, and have docker daemons "join" the swarm manager using the swarm's identifier. The docker client connects to the swarm manager as if it were a regular docker server.

当容器从Swarm启动时,它会自动分配到一个满足已定义约束的空闲节点。以下示例来自博客文章:

When a container started with Swarm, it is automatically assigned to a free node that meets any constraints that have been defined. The following example is taken from the blog post:

$ docker run -d -P -e constraint:storage=ssd mysql

支持的约束之一是node这允许您将容器固定到特定的主机名。群组还解决了节点之间的链接。

One of the supported constraints is "node" that allows you you pin a container to a specific hostname. The swarm also resolves links across nodes.

在我的测试中,我得到了一个印象: Swarm 尚未在固定位置使用卷很好(或者至少连接它们的过程不是很直观),所以这是要记住的。

In my testing I got the impression that Swarm doesn't yet work with volumes at a fixed location very well (or at least the process of linking them is not very intuitive), so this is something to keep in mind.

Swarm 现在处于beta阶段。

Swarm is now in beta phase.

直到最近, Ambassador Pattern 是远程主机服务发现的唯一Docker-native方法。仍然可以使用此模式,并且不需要任何超出普通Docker的任何魔法,因为该模式仅由一个或多个作为代理的附加容器组成。

Until recently, the Ambassador Pattern was the only Docker-native approach to remote-host service discovery. This pattern can still be used and doesn't require any magic beyond plain Docker in that the pattern consists of only of one or more additional containers that act as proxies.

另外,有几个第三方扩展使Docker集群功能。第三方解决方案包括:

Additionally, there are several third-party extensions to make Docker cluster-capable. Third-party solutions include:


  • 连接两台主机上的Docker网桥,存在轻量级和各种解决方案,但通常有一些注意事项

  • 基于DNS的发现,例如与 skydock 和SkyDNS

  • Docker管理工具,如造船厂和Docker编排工具。有关详细的列表,请参阅此问题:如何在生产中缩放Docker容器

  • Connecting the Docker network bridges on two hosts, lightweight and various solutions exist, but generally with some caveats
  • DNS-based discovery e.g. with skydock and SkyDNS
  • Docker management tools such as Shipyard, and Docker orchestration tools. See this question for an extensive list: How to scale Docker containers in production

这篇关于如何在主机之间连接Docker服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆