本文介绍了如何远程连接到docker swarm?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从本地Mac在托管在云中的docker swarm集群上执行命令?如果是,怎么办?

我想在本地从docker swarm上执行以下命令:

docker create secret my-secret <address to local file>
docker service create --name x --secrets my-secret image
解决方案

该问题的答案可以找到此处.

对于ubuntu机器需要做的是在路径/etc/docker处定义daemon.json文件,其内容如下:

  {
    "hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]
  }

上面的配置是不安全的,如果服务器是公共托管的,则不应使用.

对于安全连接,请使用以下配置:

{
  "tls": true,
  "tlscert": "/var/docker/server.pem",
  "tlskey": "/var/docker/serverkey.pem",
  "hosts": ["tcp://x.x.x.y:2376", "unix:///var/run/docker.sock"]
}

可以在此处中找到生成证书的详细信息,如@BMitch所述./p>

Is it possible to execute commands on a docker swarm cluster hosted in cloud from my local mac? If yes, how?

I want to execute command such as following on docker swarm from my local:

docker create secret my-secret <address to local file>
docker service create --name x --secrets my-secret image
解决方案

Answer to the question can be found here.

What one needs to do for ubuntu machine is define daemon.json file at path /etc/docker with following content:

  {
    "hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]
  }

The above configuration is unsecured and shouldn't be used if server is publicly hosted.

For secured connection use following config:

{
  "tls": true,
  "tlscert": "/var/docker/server.pem",
  "tlskey": "/var/docker/serverkey.pem",
  "hosts": ["tcp://x.x.x.y:2376", "unix:///var/run/docker.sock"]
}

Details for generating certificate can be found here as mentioned by @BMitch.

这篇关于如何远程连接到docker swarm?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 04:59