Terraform unable to get docker to join swarm

0 votes

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?

Aug 24, 2018 in Docker by lina
• 8,110 points

retagged Nov 12, 2018 by Omkar 88 views

1 answer to this question.

0 votes

4th line of your code is incomplete

You must specify what token you want to print [worker|manager]

answered Aug 24, 2018 by Nilesh
• 6,880 points

Related Questions In Docker

+2 votes
1 answer

Nodes not able to join docker swarm cluster

You need to provide more information like ...READ MORE

answered Sep 26, 2018 in Docker by Kalgi
• 40,420 points
195 views
0 votes
1 answer

How to send docker using terraform to aws cloudwatch?

Check if you set all the permissions ...READ MORE

answered Jun 7, 2018 in Docker by DareDev
• 6,810 points
374 views
0 votes
1 answer

How do I scale in Docker Swarm Mode W/Terraform Digital Ocean Load Balancing

The solution you could build for Digital ...READ MORE

answered Jun 19, 2018 in Docker by shubham
• 6,890 points
197 views
0 votes
1 answer

Error “unable to resolve host docker”

This error occurs because its not a ...READ MORE

answered Jul 10, 2018 in Docker by Kalgi
• 2,620 points
315 views
0 votes
1 answer
+5 votes
7 answers

Docker swarm vs kubernetes

Swarm is easy handling while kn8 is ...READ MORE

answered Aug 27, 2018 in Docker by Mahesh Ajmeria
996 views
0 votes
1 answer

Docker-Swarm: Join a docker-swarm from another subnet

You need the following ports open between ...READ MORE

answered Aug 22, 2018 in Docker by Nilesh
• 6,880 points
191 views
0 votes
1 answer

swarm manager does not connect to nodes docker daemons on AWS

You first need to ssh into the ...READ MORE

answered Aug 24, 2018 in Docker by Nilesh
• 6,880 points
80 views