gpt4 book ai didi

amazon-web-services - Terraform 无法让 docker 加入 swarm

转载 作者:行者123 更新时间:2023-12-02 04:34:38 25 4
gpt4 key购买 nike

我正在尝试使用 Terraform 启动一些 EC2 服务器,我将 Docker 群配置为在其上运行。我在 this github repo 上获得了所有代码.

错误

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} 返回 token 。

最佳答案

首先,第4行代码不完整;您必须指定要打印的 token [worker|manager]

请确保 docker 守护进程正在管理器和工作实例上运行。并且您的防火墙规则也已在两个实例上正确设置。

关于amazon-web-services - Terraform 无法让 docker 加入 swarm,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44741460/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com