github.com/hobbeswalsh/terraform@v0.3.7-0.20150619183303-ad17cf55a0fa/website/source/docs/providers/docker/r/container.html.markdown (about) 1 --- 2 layout: "docker" 3 page_title: "Docker: docker_container" 4 sidebar_current: "docs-docker-resource-container" 5 description: |- 6 Manages the lifecycle of a Docker container. 7 --- 8 9 # docker\_container 10 11 Manages the lifecycle of a Docker container. 12 13 ## Example Usage 14 15 ``` 16 # Start a container 17 resource "docker_container" "ubuntu" { 18 name = "foo" 19 image = "${docker_image.ubuntu.latest}" 20 } 21 22 # Find the latest Ubuntu precise image. 23 resource "docker_image" "ubuntu" { 24 image = "ubuntu:precise" 25 } 26 ``` 27 28 ## Argument Reference 29 30 The following arguments are supported: 31 32 * `name` - (Required, string) The name of the Docker container. 33 * `image` - (Required, string) The ID of the image to back this container. 34 The easiest way to get this value is to use the `docker_image` resource 35 as is shown in the example above. 36 37 * `command` - (Optional, list of strings) The command to use to start the 38 container. 39 * `dns` - (Optional, set of strings) Set of DNS servers. 40 * `env` - (Optional, set of strings) Environmental variables to set. 41 * `links` - (Optional, set of strings) Set of links for link based 42 connectivity between containers that are running on the same host. 43 * `hostname` - (Optional, string) Hostname of the container. 44 * `domainname` - (Optional, string) Domain name of the container. 45 * `must_run` - (Optional, bool) If true, then the Docker container will be 46 kept running. If false, then as long as the container exists, Terraform 47 assumes it is successful. 48 * `ports` - (Optional) See [Ports](#ports) below for details. 49 * `privileged` - (Optional, bool) Run container in privileged mode. 50 * `publish_all_ports` - (Optional, bool) Publish all ports of the container. 51 * `volumes` - (Optional) See [Volumes](#volumes) below for details. 52 53 <a id="ports"></a> 54 ## Ports 55 56 `ports` is a block within the configuration that can be repeated to specify 57 the port mappings of the container. Each `ports` block supports 58 the following: 59 60 * `internal` - (Required, int) Port within the container. 61 * `external` - (Required, int) Port exposed out of the container. 62 * `ip` - (Optional, string) IP address/mask that can access this port. 63 * `protocol` - (Optional, string) Protocol that can be used over this port, 64 defaults to TCP. 65 66 <a id="volumes"></a> 67 ## Volumes 68 69 `volumes` is a block within the configuration that can be repeated to specify 70 the volumes attached to a container. Each `volumes` block supports 71 the following: 72 73 * `from_container` - (Optional, string) The container where the volume is 74 coming from. 75 * `container_path` - (Optional, string) The path in the container where the 76 volume will be mounted. 77 * `host_path` - (Optional, string) The path on the host where the volume 78 is coming from. 79 * `read_only` - (Optinal, bool) If true, this volume will be readonly. 80 Defaults to false. 81 82 ## Attributes Reference 83 84 The following attributes are exported: 85 86 * `ip_address` - The IP address of the container as read from its 87 NetworkSettings. 88 * `ip_prefix_length` - The IP prefix length of the container as read from its 89 NetworkSettings. 90 * `gateway` - The network gateway of the container as read from its 91 NetworkSettings. 92 * `bridge` - The network bridge of the container as read from its 93 NetworkSettings.