我将使用Terraform来启动一些EC2服务器,并配置Docker swarm运行。我已经将所有代码放在这个Github仓库中。
错误信息:
使用--token的代码
aws_instance.swarm-node.0 (remote-exec): Connected!
aws_instance.swarm-node.0 (remote-exec): Cannot connect to the Docker daemon. Is the docker daemon running on this host?
aws_instance.swarm-node.0 (remote-exec): flag needs an argument: --token
aws_instance.swarm-node.0 (remote-exec): See 'docker swarm join --help'.
使用--token的代码
provisioner "remote-exec" {
inline = [
"echo ===================================",
"echo JOIN-TOKEN: `docker -H ${aws_instance.swarm-manager.0.private_ip} swarm join-token -q` ",
"echo ===================================",
"echo ===================================",
"sudo docker swarm join ${aws_instance.swarm-manager.0.private_ip}:2377 --token $(docker -H ${aws_instance.swarm-manager.0.private_ip} swarm join-token -q worker)"
]
}
上述命令的输出结果:
aws_instance.swarm-node.1 (remote-exec): Usage: docker swarm join-token [-q] [--rotate] (worker|manager)
aws_instance.swarm-node.1 (remote-exec): Manage join tokens
aws_instance.swarm-node.1 (remote-exec): JOIN-TOKEN:
aws_instance.swarm-node.1 (remote-exec): ===================================
aws_instance.swarm-node.1 (remote-exec): ===================================
aws_instance.swarm-node.1 (remote-exec): ===================================
aws_instance.swarm-node.1 (remote-exec): ===================================
aws_instance.swarm-node.1 (remote-exec): ===================================
aws_instance.swarm-node.1 (remote-exec): Cannot connect to the Docker daemon. Is the docker daemon running on this host?
aws_instance.swarm-node.1 (remote-exec): flag needs an argument: --token
我该怎么做才能使$(docker -H ${aws_instance.swarm-manager.0.private_ip}
返回一个令牌?
docker -H ${aws_instance.swarm-manager.0.private_ip} swarm join-token -q worker
返回一个令牌吗? - gesellix