github.com/leeprovoost/terraform@v0.6.10-0.20160119085442-96f3f76118e7/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  * `host_entry` - (Optional) See [Extra Hosts](#extra_hosts) below for details.
    61  * `privileged` - (Optional, bool) Run container in privileged mode.
    62  * `publish_all_ports` - (Optional, bool) Publish all ports of the container.
    63  * `volumes` - (Optional) See [Volumes](#volumes) below for details.
    64  * `memory` - (Optional, int) The memory limit for the container in MBs.
    65  * `memory_swap` - (Optional, int) The total memory limit (memory + swap) for the
    66    container in MBs.
    67  * `cpu_shares` - (Optional, int) CPU shares (relative weight) for the container.
    68  * `log_driver` - (Optional, string) The logging driver to use for the container.
    69    Defaults to "json-file".
    70  * `log_opts` - (Optional) Key/value pairs to use as options for the logging
    71    driver.
    72  * `network_mode` - (Optional) Network mode of the container.
    73  * `networks` - (Optional, set of strings) Id of the networks in which the container is.
    74  
    75  <a id="ports"></a>
    76  ## Ports
    77  
    78  `ports` is a block within the configuration that can be repeated to specify
    79  the port mappings of the container. Each `ports` block supports
    80  the following:
    81  
    82  * `internal` - (Required, int) Port within the container.
    83  * `external` - (Required, int) Port exposed out of the container.
    84  * `ip` - (Optional, string) IP address/mask that can access this port.
    85  * `protocol` - (Optional, string) Protocol that can be used over this port,
    86    defaults to TCP.
    87  
    88  <a id="extra_hosts"></a>
    89  ## Extra Hosts
    90  
    91  `host_entry` is a block within the configuration that can be repeated to specify
    92  the extra host mappings for the container. Each `host_entry` block supports
    93  the following:
    94  
    95  * `host` - (Required, int) Hostname to add.
    96  * `ip` - (Required, int) IP address this hostname should resolve to..
    97  
    98  This is equivalent to using the `--add-host` option when using the `run`
    99  command of the Docker CLI.
   100  
   101  <a id="volumes"></a>
   102  ## Volumes
   103  
   104  `volumes` is a block within the configuration that can be repeated to specify
   105  the volumes attached to a container. Each `volumes` block supports
   106  the following:
   107  
   108  * `from_container` - (Optional, string) The container where the volume is
   109    coming from.
   110  * `host_path` - (Optional, string) The path on the host where the volume
   111    is coming from.
   112  * `volume_name` - (Optional, string) The name of the docker volume which
   113    should be mounted.
   114  * `container_path` - (Optional, string) The path in the container where the
   115    volume will be mounted.
   116  * `read_only` - (Optional, bool) If true, this volume will be readonly.
   117    Defaults to false.
   118    
   119  One of `from_container`, `host_path` or `volume_name` must be set.
   120  
   121  ## Attributes Reference
   122  
   123  The following attributes are exported:
   124  
   125   * `ip_address` - The IP address of the container as read from its
   126     NetworkSettings.
   127   * `ip_prefix_length` - The IP prefix length of the container as read from its
   128     NetworkSettings.
   129   * `gateway` - The network gateway of the container as read from its
   130     NetworkSettings.
   131   * `bridge` - The network bridge of the container as read from its
   132     NetworkSettings.