github.com/armen/terraform@v0.5.2-0.20150529052519-caa8117a08f1/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 * `publish_all_ports` - (Optional, bool) Publish all ports of the container. 50 * `volumes` - (Optional) See [Volumes](#volumes) below for details. 51 52 <a id="ports"></a> 53 ## Ports 54 55 `ports` is a block within the configuration that can be repeated to specify 56 the port mappings of the container. Each `ports` block supports 57 the following: 58 59 * `internal` - (Required, int) Port within the container. 60 * `external` - (Required, int) Port exposed out of the container. 61 * `ip` - (Optional, string) IP address/mask that can access this port. 62 * `protocol` - (Optional, string) Protocol that can be used over this port, 63 defaults to TCP. 64 65 <a id="volumes"></a> 66 ## Volumes 67 68 `volumes` is a block within the configuration that can be repeated to specify 69 the volumes attached to a container. Each `volumes` block supports 70 the following: 71 72 * `from_container` - (Optional, string) The container where the volume is 73 coming from. 74 * `container_path` - (Optional, string) The path in the container where the 75 volume will be mounted. 76 * `host_path` - (Optional, string) The path on the host where the volume 77 is coming from. 78 * `read_only` - (Optinal, bool) If true, this volume will be readonly. 79 Defaults to false. 80 81 ## Attributes Reference 82 83 The following attributes are exported: 84 85 * `ip_address` - The IP address of the container as read from its 86 NetworkSettings. 87 * `ip_prefix_length` - The IP prefix length of the container as read from its 88 NetworkSettings. 89 * `gateway` - The network gateway of the container as read from its 90 NetworkSettings. 91 * `bridge` - The network bridge of the container as read from its 92 NetworkSettings.