From f74405d5e726ee8729c90ca1fa70972d4cdc9c22 Mon Sep 17 00:00:00 2001 From: Nick Downs Date: Thu, 16 Apr 2015 12:42:21 -0700 Subject: [PATCH] Added Docker links support to the docker_container resource. --- builtin/providers/docker/resource_docker_container.go | 8 ++++++++ .../providers/docker/resource_docker_container_funcs.go | 4 ++++ .../docs/providers/docker/r/container.html.markdown | 2 ++ 3 files changed, 14 insertions(+) diff --git a/builtin/providers/docker/resource_docker_container.go b/builtin/providers/docker/resource_docker_container.go index 50b501ca2..de0b0b667 100644 --- a/builtin/providers/docker/resource_docker_container.go +++ b/builtin/providers/docker/resource_docker_container.go @@ -108,6 +108,14 @@ func resourceDockerContainer() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, Set: stringSetHash, }, + + "links": &schema.Schema{ + Type: schema.TypeSet, + Optional: true, + ForceNew: true, + Elem: &schema.Schema{Type: schema.TypeString}, + Set: stringSetHash, + }, }, } } diff --git a/builtin/providers/docker/resource_docker_container_funcs.go b/builtin/providers/docker/resource_docker_container_funcs.go index 17a8e4eed..ae0a6e6bd 100644 --- a/builtin/providers/docker/resource_docker_container_funcs.go +++ b/builtin/providers/docker/resource_docker_container_funcs.go @@ -103,6 +103,10 @@ func resourceDockerContainerCreate(d *schema.ResourceData, meta interface{}) err hostConfig.DNS = stringSetToStringSlice(v.(*schema.Set)) } + if v, ok := d.GetOk("links"); ok { + hostConfig.Links = stringSetToStringSlice(v.(*schema.Set)) + } + if err := client.StartContainer(retContainer.ID, hostConfig); err != nil { return fmt.Errorf("Unable to start container: %s", err) } diff --git a/website/source/docs/providers/docker/r/container.html.markdown b/website/source/docs/providers/docker/r/container.html.markdown index 418e35fc1..ebeabaa00 100644 --- a/website/source/docs/providers/docker/r/container.html.markdown +++ b/website/source/docs/providers/docker/r/container.html.markdown @@ -38,6 +38,8 @@ The following arguments are supported: container. * `dns` - (Optional, set of strings) Set of DNS servers. * `env` - (Optional, set of strings) Environmental variables to set. +* `links` - (Optional, set of strings) Set of links for link based + connectivity between containers that are running on the same host. * `hostname` - (Optional, string) Hostname of the container. * `domainname` - (Optional, string) Domain name of the container. * `must_run` - (Optional, bool) If true, then the Docker container will be