github.com/turtlemonvh/terraform@v0.6.9-0.20151204001754-8e40b6b855e8/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 name = "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. For example, to run `/usr/bin/myprogram -f baz.conf` set the 39 command to be `["/usr/bin/myprogram", "-f", "baz.conf"]`. 40 * `entrypoint` - (Optional, list of strings) The command to use as the 41 Entrypoint for the container. The Entrypoint allows you to configure a 42 container to run as an executable. For example, to run `/usr/bin/myprogram` 43 when starting a container, set the entrypoint to be 44 `["/usr/bin/myprogram"]`. 45 * `dns` - (Optional, set of strings) Set of DNS servers. 46 * `env` - (Optional, set of strings) Environmental variables to set. 47 * `labels` - (Optional) Key/value pairs to set as labels on the container. 48 * `links` - (Optional, set of strings) Set of links for link based 49 connectivity between containers that are running on the same host. 50 * `hostname` - (Optional, string) Hostname of the container. 51 * `domainname` - (Optional, string) Domain name of the container. 52 * `restart` - (Optional, string) The restart policy for the container. Must be 53 one of "no", "on-failure", "always". 54 * `max_retry_count` - (Optional, int) The maximum amount of times to an attempt 55 a restart when `restart` is set to "on-failure" 56 * `must_run` - (Optional, bool) If true, then the Docker container will be 57 kept running. If false, then as long as the container exists, Terraform 58 assumes it is successful. 59 * `ports` - (Optional) See [Ports](#ports) below for details. 60 * `privileged` - (Optional, bool) Run container in privileged mode. 61 * `publish_all_ports` - (Optional, bool) Publish all ports of the container. 62 * `volumes` - (Optional) See [Volumes](#volumes) below for details. 63 * `memory` - (Optional, int) The memory limit for the container in MBs. 64 * `memory_swap` - (Optional, int) The total memory limit (memory + swap) for the 65 container in MBs. 66 * `cpu_shares` - (Optional, int) CPU shares (relative weight) for the container. 67 * `log_driver` - (Optional, string) The logging driver to use for the container. 68 Defaults to "json-file". 69 * `log_opts` - (Optional) Key/value pairs to use as options for the logging 70 driver. 71 72 <a id="ports"></a> 73 ## Ports 74 75 `ports` is a block within the configuration that can be repeated to specify 76 the port mappings of the container. Each `ports` block supports 77 the following: 78 79 * `internal` - (Required, int) Port within the container. 80 * `external` - (Required, int) Port exposed out of the container. 81 * `ip` - (Optional, string) IP address/mask that can access this port. 82 * `protocol` - (Optional, string) Protocol that can be used over this port, 83 defaults to TCP. 84 85 <a id="volumes"></a> 86 ## Volumes 87 88 `volumes` is a block within the configuration that can be repeated to specify 89 the volumes attached to a container. Each `volumes` block supports 90 the following: 91 92 * `from_container` - (Optional, string) The container where the volume is 93 coming from. 94 * `container_path` - (Optional, string) The path in the container where the 95 volume will be mounted. 96 * `host_path` - (Optional, string) The path on the host where the volume 97 is coming from. 98 * `read_only` - (Optional, bool) If true, this volume will be readonly. 99 Defaults to false. 100 101 ## Attributes Reference 102 103 The following attributes are exported: 104 105 * `ip_address` - The IP address of the container as read from its 106 NetworkSettings. 107 * `ip_prefix_length` - The IP prefix length of the container as read from its 108 NetworkSettings. 109 * `gateway` - The network gateway of the container as read from its 110 NetworkSettings. 111 * `bridge` - The network bridge of the container as read from its 112 NetworkSettings.