我正在尝试使用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-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)
是否有可能调试群机以找到最终错误的配置?
答案 0 :(得分:0)
我发现在docker主机中运行了一个docker swarm实例。我建立的连接是对接器主机而不是其中的swarm实例。旗帜" - 群体"是达到swarm实例的关键,在我的情况下这是遗漏的。
以下是检查docker host的环境变量的命令:
$ 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信息的输出显示了我的预期:
$ 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)
希望这可以帮助别人。