github.com/nicgrayson/terraform@v0.4.3-0.20150415203910-c4de50829380/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 * `hostname` - (Optional, string) Hostname of the container. 42 * `domainname` - (Optional, string) Domain name of the container. 43 * `must_run` - (Optional, bool) If true, then the Docker container will be 44 kept running. If false, then as long as the container exists, Terraform 45 assumes it is successful. 46 * `ports` - (Optional) See [Ports](#ports) below for details. 47 * `publish_all_ports` - (Optional, bool) Publish all ports of the container. 48 * `volumes` - (Optional) See [Volumes](#volumes) below for details. 49 50 <a id="ports"></a> 51 ## Ports 52 53 `ports` is a block within the configuration that can be repeated to specify 54 the port mappings of the container. Each `ports` block supports 55 the following: 56 57 * `internal` - (Required, int) Port within the container. 58 * `external` - (Required, int) Port exposed out of the container. 59 * `ip` - (Optional, string) IP address/mask that can access this port. 60 * `protocol` - (Optional, string) Protocol that can be used over this port, 61 defaults to TCP. 62 63 <a id="volumes"></a> 64 ## Volumes 65 66 `volumes` is a block within the configuration that can be repeated to specify 67 the volumes attached to a container. Each `volumes` block supports 68 the following: 69 70 * `from_container` - (Optional, string) The container where the volume is 71 coming from. 72 * `container_path` - (Optional, string) The path in the container where the 73 volume will be mounted. 74 * `host_path` - (Optional, string) The path on the host where the volume 75 is coming from. 76 * `read_only` - (Optinal, bool) If true, this volume will be readonly. 77 Defaults to false.