I'm trying to use Terraform to spin up some EC2 server which I configure Docker swarm to run on
I'm getting the following error
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'.
The code that uses --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)"
]
}
The output from the command above:
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
Where am i going wrong?