Travis CI上的Docker Swarm设置:有关尝试添加工作节点的帮助
我正在尝试在Travis CI上的Docker(dind)设置中配置Docker,因为我正在开发/工作在Docker集群群上,并且希望设置一个测试环境来模拟生产站点。
相关信息
swarm-manager
和swarm-worker
docker:18.06-dind
docker-compose.yml
的内容:version: '3'
services:
swarm-manager:
image: docker:18.09-dind
container_name: swarm-manager
privileged: true
networks:
- test_network
swarm-worker:
image: docker:18.09-dind
container_name: swarm-worker
privileged: true
networks:
- test_network
networks:
test_network:
初始设置
docker-compose up -d
docker exec -it swarm-manager docker swarm init
export WORKER_TOKEN=$(docker exec -it swarm-manager docker swarm join-token -q worker)
在这一点上,docker-manager
已设置为具有初始化的群集模式并接受来自工作程序节点的连接,并且我也有一个有效的--token
,例如
echo $WORKER_TOKEN
SWMTKN-1-3fbgb7mpxl7fi8ec6y5fhe9sqa32b4cxls8x1yy6pry0uqk2et-8jdbm37imsxrzqc1aycbekvee
但是,一旦尝试使用以下命令添加swarm-worker
,就会收到错误消息:
docker exec -it -e WORKER_TOKEN swarm-worker docker swarm join swarm-manager:2377 --token $WORKER_TOKEN
错误消息
Error response from daemon: invalid join token
因此,我知道WORKER_TOKEN
参数在swarm-worker
环境中,因为
docker exec -it -e WORKER_TOKEN swarm-worker sh -c export
收益
export DIND_COMMIT='37498f009d8bf25fbb6199e8ccd34bed84f2874b'
export DOCKER_CHANNEL='stable'
export DOCKER_VERSION='18.09.6'
export HOME='/root'
export HOSTNAME='d656ad182e06'
export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
export PWD='/'
export SHLVL='1'
export TERM='xterm'
export WORKER_TOKEN='SWMTKN-1-3fbgb7mpxl7fi8ec6y5fhe9sqa32b4cxls8x1yy6pry0uqk2et-8jdbm37imsxrzqc1aycbekvee
我想成功地将swarm-worker
添加为docker群中的工作节点。任何帮助,将不胜感激。