首页 \ 问答 \ 需要Docker引擎群模式的服务发现(Need for service discovery for docker engine swarm mode)

需要Docker引擎群模式的服务发现(Need for service discovery for docker engine swarm mode)

我对码头群感到困惑。 据我所知,运行swarm的旧方法是在docker引擎为swarm模式提供本机支持之前运行容器中的经理和工作人员。 旧的集装箱式swarm的文档解释了如何使用consul,etcd或zookeeper设置服务发现。 服务发现是必要的,因为服务是在随机端口上运行以避免冲突,对吧?

码头引擎群模式的文档没有解释如何设置服务发现。 现在我很困惑,如果机制包含在swarm模式中,或者文档不完整。

在哪里可以找到有关群模式的清晰,最新的解释,以及它与服务发现等概念的关系?


I'm confused about docker swarm. As far as I know, the old way to run a swarm was to run manager and workers in containers, before docker engine provided native support for swarm mode. Documentation for the old, containerized swarm explained how to setup service discovery using consul, etcd or zookeeper. Service discovery is necessary, as services are ran at random ports to avoid collisions, right?

Documentation for the docker engine swarm mode doesn't explain how to setup service discovery. Now I'm confused, if the mechanism is included in swarm mode, or is the documentation incomplete.

Where I can find clear, up-to-date explanation of swarm mode, and how it relates to concepts like service discovery?


原文:https://stackoverflow.com/questions/40786414
更新时间:2023-03-20 07:03

最满意答案

您可以通过单个XPath表达式选择所需的内容,如此转换所示:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output omit-xml-declaration="yes" indent="yes"/>
 <xsl:strip-space elements="*"/>

 <xsl:template match="sourceElement">
     <xsl:copy-of select=
     "document('file:///c:/temp/delete/dept.xml')
               /*/*[child1 = current()]
                     /*[not(self::child1)]
     "/>
 </xsl:template>
</xsl:stylesheet>

当此转换应用于提供的XML文档时:

<sourceRoot>
 <sourceElement>foo</sourceElement>
</sourceRoot>

第二个提供的XML文档驻留在c:\temp\delete\dept.xml的本地文件系统中:

<departments>
 <department>
  <child1>bar</child1>
  <child2>bar2</child2>
  <child3>bar3</child3>
 </department>
 <department>
  <child1>baz</child1>
  <child2>baz2</child2>
  <child3>baz3</child3>
 </department>
 <department>
  <child1>foo</child1>
  <child2>foo2</child2>
  <child3>foo3</child3>
 </department>
</departments>

产生了想要的正确结果:

<child2>foo2</child2>
<child3>foo3</child3>

更新

如果我们想要更改上面所选元素的名称,这非常简单:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output omit-xml-declaration="yes" indent="yes"/>
 <xsl:strip-space elements="*"/>

 <xsl:template match="sourceElement">
     <xsl:apply-templates select=
     "document('file:///c:/temp/delete/dept.xml')
               /*/*[child1 = current()]
                     /*[not(self::child1)]
     "/>
 </xsl:template>

 <xsl:template match="*[starts-with(name(), 'child')]">
  <xsl:element name="{name()}value"><xsl:value-of select="."/></xsl:element>
 </xsl:template>
</xsl:stylesheet>

产生

<child2value>foo2</child2value>
<child3value>foo3</child3value>

What you want can be selected by a single XPath expression, as demonstrated with this transformation:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output omit-xml-declaration="yes" indent="yes"/>
 <xsl:strip-space elements="*"/>

 <xsl:template match="sourceElement">
     <xsl:copy-of select=
     "document('file:///c:/temp/delete/dept.xml')
               /*/*[child1 = current()]
                     /*[not(self::child1)]
     "/>
 </xsl:template>
</xsl:stylesheet>

when this transformation is applied on the provided XML document:

<sourceRoot>
 <sourceElement>foo</sourceElement>
</sourceRoot>

and the second provided XML document resides in the local file system at c:\temp\delete\dept.xml:

<departments>
 <department>
  <child1>bar</child1>
  <child2>bar2</child2>
  <child3>bar3</child3>
 </department>
 <department>
  <child1>baz</child1>
  <child2>baz2</child2>
  <child3>baz3</child3>
 </department>
 <department>
  <child1>foo</child1>
  <child2>foo2</child2>
  <child3>foo3</child3>
 </department>
</departments>

the wanted, correct result is produced:

<child2>foo2</child2>
<child3>foo3</child3>

Update:

If we want to change the names of the selected elements above, this is really simple:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output omit-xml-declaration="yes" indent="yes"/>
 <xsl:strip-space elements="*"/>

 <xsl:template match="sourceElement">
     <xsl:apply-templates select=
     "document('file:///c:/temp/delete/dept.xml')
               /*/*[child1 = current()]
                     /*[not(self::child1)]
     "/>
 </xsl:template>

 <xsl:template match="*[starts-with(name(), 'child')]">
  <xsl:element name="{name()}value"><xsl:value-of select="."/></xsl:element>
 </xsl:template>
</xsl:stylesheet>

produces:

<child2value>foo2</child2value>
<child3value>foo3</child3value>

相关问答

更多

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。