terra-farm / terraform-provider-virtualbox

VirtualBox provider for Terraform
https://terra-farm.github.io/provider-virtualbox/
MIT License
323 stars 134 forks source link

Error using provider docker #28

Closed DblK closed 6 years ago

DblK commented 6 years ago

Hi,

I successfully have been able to create virtualbox machine with this provider, however when I try to use the provider docker with the IP created by this provider I have the following error: provider.docker: Error pinging Docker server: cannot connect to Docker endpoint

Here is the code I used:

# Configure the Docker provider
provider "docker" {
  # host = "unix:///var/run/docker.sock" # Working but not inside the virtualbox machine
  # host = "tcp://${element(virtualbox_vm.node.*.network_adapter.0.ipv4_address, 1)}:2376/" # Not working
  host = "tcp://${element(virtualbox_vm.node.*.network_adapter.0.ipv4_address, 1)}:2375/"
}

resource "docker_image" "ubuntu" {
  name = "ubuntu:latest"
}

# Create a container
resource "docker_container" "foo" {
  image = "${docker_image.ubuntu.latest}"
  name  = "foo"
}

Any idea why it's failing? Or I should use remote-exec instead?

Thx

ringods commented 6 years ago

@DblK I suspect you have to start the Docker daemon on the vbox vm to expose the management socket on the ethernet interface of th VM. This is not the case by default. See the Docker daemon settings for more info: https://docs.docker.com/engine/reference/commandline/dockerd/#examples

Since this issue is not related to the virtualbox provider, I'm going to close it.