hashicorp / terraform-provider-docker

As part of our introduction to self-service publishing in the Terraform Registry, this copy of the provider has been archived, and ownership has been transferred to active maintainers in the community. Please see the new location on the Terraform Registry: https://registry.terraform.io/providers/kreuzwerker/docker/latest
https://registry.terraform.io/providers/kreuzwerker/docker/latest
Mozilla Public License 2.0
132 stars 91 forks source link

IPv6 attributes inaccessible from `network_data` #265

Closed ellsclytn closed 4 years ago

ellsclytn commented 4 years ago

Terraform Version

Terraform v0.12.24

Affected Resource(s)

Terraform Configuration Files

provider "docker" {
  host = "ssh://terraformtest"
}

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

# Create a container
resource "docker_container" "caddy_test" {
  image = docker_image.caddy.latest
  name  = "caddy_test"

  volumes {
    host_path = "/home/test/test_serve/index.html"
    container_path = "/usr/share/caddy/index.html"
    read_only = true
  }

  volumes {
    host_path = "/home/test/test_serve/data"
    container_path = "/data"
  }
}

output "network_data" {
  value = docker_container.caddy_test.network_data
}

Expected Behavior

The network_data attribute provides ipv6_address, ipv6_gateway properties to access.

Actual Behavior

The network_data attribute provides only IPv4 related data, regardless of whether the container is IPv6 enabled.

Steps to Reproduce

  1. Enable IPv6 within the docker daemon on the target machine. This can be achieved by adding configuration similar to the below to /etc/docker/daemon.json. The docker daemon will need to be restarted on the target machine.
{
  "ipv6": true,
  "fixed-cidr-v6": "2403:1234:1234:1234::/80"
}
  1. Run terraform apply with the configuration above
  2. The docker container will have an IPv6 address assigned by Docker, though it will be inaccessible from Terraform attributes. docker inspect [container_id] may be performed on the target machine as a means of verifying this.

Important Factoids

I'm aware one can statically assign IPv6 addresses to containers, and this could be used as a workaround of sorts. However, I'm specifically interested in leveraging Docker's ability to assign addresses within the subnet automatically, to minimise manual effort.