0

我正在尝试使用 docker swarm 引擎并遵循官方文档创建容器集群:https ://docs.docker.com/swarm/install-w-machine/ 。但遗憾的是直到现在都没有成功。

在文档获取有关 swarm 的信息的步骤中,只显示了两个容器(来自 swarm-master 的容器)而不是四个。这是我得到的输出:

$ docker info
Containers: 2
Images: 7
Storage Driver: aufs
 Root Dir: /mnt/sda1/var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 11
 Dirperm1 Supported: true
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 4.0.5-boot2docker
Operating System: Boot2Docker 1.7.0 (TCL 6.3); master : 7960f90 - Thu Jun 18     18:31:45 UTC 2015
CPUs: 1
Total Memory: 996.2 MiB
Name: swarm-master
ID: M4Z4:6ZBE:LV53:NHS3:7CT6:HNWM:GLQ4:5WPY:3CZR:HVAZ:GPP2:G7I3
Debug mode (server): true
File Descriptors: 20
Goroutines: 33
System Time: 2015-06-29T15:36:40.543771252Z
EventsListeners: 0
Init SHA1:
Init Path: /usr/local/bin/docker
Docker Root Dir: /mnt/sda1/var/lib/docker
Labels:
 provider=virtualbox

当前的 docker 机器有:

$ docker-machine ls
local                     virtualbox   Running   tcp://192.168.99.100:2376
swarm-agent-00            virtualbox   Running   tcp://192.168.99.102:2376       swarm-master
swarm-agent-01            virtualbox   Running   tcp://192.168.99.103:2376       swarm-master
swarm-master     *        virtualbox   Running   tcp://192.168.99.101:2376       swarm-master (master)

是否有可能调试 swarm 机器以找到最终的错误配置?

4

1 回答 1

0

我发现在 docker 主机中运行了一个 docker swarm 实例。我建立的连接是到 docker 主机,而不是到其中的 swarm 实例。标志“--swarm”是到达 swarm 实例的关键,在我的例子中是缺失的。

以下是检查 docker 主机环境变量的命令:

 $ docker-machine env swarm-master
 export DOCKER_TLS_VERIFY="1"
 export DOCKER_HOST="tcp://192.168.99.100:2376"
 export DOCKER_CERT_PATH="/home/bksoft/.docker/machine/machines/swarm-master"
 export DOCKER_MACHINE_NAME="swarm-master"
 # Run this command to configure your shell:
 # eval "$(docker-machine env swarm-master)"

以及检查 docker swarm 实例的命令:

 $ docker-machine env --swarm swarm-master
 export DOCKER_TLS_VERIFY="1"
 export DOCKER_HOST="tcp://192.168.99.100:3376"
 export DOCKER_CERT_PATH="/home/bksoft/.docker/machine/machines/swarm-master"
 export DOCKER_MACHINE_NAME="swarm-master"
 # Run this command to configure your shell:
 # eval "$(docker-machine env swarm-master)"

男人认出了不同的暴露端口“2376”和“3376”。

现在 docker info 的输出显示了我的预期:

$ docker info
Containers: 5
Images: 3
Role: primary
Strategy: spread
Filters: affinity, health, constraint, port, dependency
Nodes: 3
 swarm-agent-00: 192.168.99.101:2376
  â Containers: 1
  â Reserved CPUs: 0 / 1
  â Reserved Memory: 0 B / 1.022 GiB
  â Labels: executiondriver=native-0.2, kernelversion=4.0.5-boot2docker,     operatingsystem=Boot2Docker 1.7.0 (TCL 6.3); master : 7960f90 - Thu Jun 18     18:31:45 UTC 2015, provider=virtualbox, storagedriver=aufs
 swarm-agent-01: 192.168.99.102:2376
  â Containers: 1
  â Reserved CPUs: 0 / 1
  â Reserved Memory: 0 B / 1.022 GiB
  â Labels: executiondriver=native-0.2, kernelversion=4.0.5-boot2docker,     operatingsystem=Boot2Docker 1.7.0 (TCL 6.3); master : 7960f90 - Thu Jun 18     18:31:45 UTC 2015, provider=virtualbox, storagedriver=aufs
 swarm-master: 192.168.99.100:2376
  â Containers: 3
  â Reserved CPUs: 0 / 1
  â Reserved Memory: 0 B / 1.022 GiB
  â Labels: executiondriver=native-0.2, kernelversion=4.0.5-boot2docker,     operatingsystem=Boot2Docker 1.7.0 (TCL 6.3); master : 7960f90 - Thu Jun 18     18:31:45 UTC 2015, provider=virtualbox, storagedriver=aufs
CPUs: 3
Total Memory: 3.065 GiB

虚拟机的输出也不同。不显示星号来指向当前活动机器:

$ docker-machine ls
NAME             ACTIVE   DRIVER       STATE     URL                             SWARM
swarm-agent-00            virtualbox   Running   tcp://192.168.99.101:2376       swarm-master
swarm-agent-01            virtualbox   Running   tcp://192.168.99.102:2376       swarm-master
swarm-master              virtualbox   Running   tcp://192.168.99.100:2376       swarm-master (master)

希望这可以帮助别人。

于 2015-06-30T11:42:58.113 回答