Terraform Docker provider gives me a "Unsupported protocol error"

926 views
Skip to first unread message

Eric B

unread,
Feb 7, 2017, 9:13:01 PM2/7/17
to Terraform
I'm trying to set up a Terraform / Docker testbed and running into some issues.  I'm new to both the Terraform and Docker worlds, so not entirely sure which is at "fault" here.

I have a CentOS7 server up and running with my docker engine running.  Running "docker run hello-world" outputs the expected Hello World.

However, when I try to launch a simple container using Terraform, I get the following error:

Eric-MacBook-Pro:bin eric$ ./terraform plan

Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to
local or remote state storage.

Error refreshing state: 1 error(s) occurred:

* Post : unsupported protocol scheme ""
Eric-MacBook-Pro:bin eric$



My .tf file has minimal config:


# Configure the Docker provider


provider "docker" {
   host = "tcp://192.168.2.215:2376/"

}


# Create a container

resource "docker_container" "foo" {

   image = "${docker_image.ubuntu.latest}"

   name = "foo"

}


resource
"docker_image" "ubuntu" {

    name = "ubuntu:latest"

}



What am I doing wrong?  What is generating the unsupported protocol scheme?  I suspect it might be a communication error, but not sure what.  I've disabled the firewall on the CentOS box, just in case something was being blocked there.


On CentOS, I don't actually see the dockerd listening to port 2376; is there something special I need to do to enable that part:


netstat -ap | grep dock

unix  
2      [ ACC ]     STREAM     LISTENING     31251    4704/dockerd         /var/run/docker.sock
unix  
2      [ ACC ]     STREAM     LISTENING     31268    4707/docker-contain  /var/run/docker/libcontainerd/docker-containerd.sock
unix  
2      [ ACC ]     STREAM     LISTENING     31430    4704/dockerd         /run/docker/libnetwork/0428d67a86e673e1177ceae7a2e8956cf9a6d9d64c164d8d8df5828d4b276d72.sock
unix  
3      [ ]         STREAM     CONNECTED     31244    4704/dockerd        
unix  
2      [ ]         DGRAM                    31249    4704/dockerd        
unix  
3      [ ]         STREAM     CONNECTED     31272    4707/docker-contain  /var/run/docker/libcontainerd/docker-containerd.sock



Thanks,

Eric


Lowe Schmidt

unread,
Feb 8, 2017, 5:06:09 AM2/8/17
to terrafo...@googlegroups.com
Have you tried setting the host to the unix socket path? 

Something like unix:///var/run/docker.sock 


--
Lowe Schmidt | +46 723 867 157

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/bb0e83ea-3e30-4b90-ad28-96399a729110%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages