github.com/andresvia/terraform@v0.6.15-0.20160412045437-d51c75946785/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  * `user` - (Optional, string) User used for run the first process. Format is
    46      `user` or `user:group` which user and group can be passed literraly or
    47      by name.
    48  * `dns` - (Optional, set of strings) Set of DNS servers.
    49  * `env` - (Optional, set of strings) Environmental variables to set.
    50  * `labels` - (Optional, map of strings) Key/value pairs to set as labels on the
    51    container.
    52  * `links` - (Optional, set of strings) Set of links for link based
    53    connectivity between containers that are running on the same host.
    54  * `hostname` - (Optional, string) Hostname of the container.
    55  * `domainname` - (Optional, string) Domain name of the container.
    56  * `restart` - (Optional, string) The restart policy for the container. Must be
    57    one of "no", "on-failure", "always", "unless-stopped".
    58  * `max_retry_count` - (Optional, int) The maximum amount of times to an attempt
    59    a restart when `restart` is set to "on-failure"
    60  * `must_run` - (Optional, bool) If true, then the Docker container will be
    61    kept running. If false, then as long as the container exists, Terraform
    62    assumes it is successful.
    63  * `ports` - (Optional, block) See [Ports](#ports) below for details.
    64  * `host_entry` - (Optional, block) See [Extra Hosts](#extra_hosts) below for
    65    details.
    66  * `privileged` - (Optional, bool) Run container in privileged mode.
    67  * `publish_all_ports` - (Optional, bool) Publish all ports of the container.
    68  * `volumes` - (Optional, block) See [Volumes](#volumes) below for details.
    69  * `memory` - (Optional, int) The memory limit for the container in MBs.
    70  * `memory_swap` - (Optional, int) The total memory limit (memory + swap) for the
    71    container in MBs.
    72  * `cpu_shares` - (Optional, int) CPU shares (relative weight) for the container.
    73  * `log_driver` - (Optional, string) The logging driver to use for the container.
    74    Defaults to "json-file".
    75  * `log_opts` - (Optional, map of strings) Key/value pairs to use as options for
    76    the logging driver.
    77  * `network_mode` - (Optional, string) Network mode of the container.
    78  * `networks` - (Optional, set of strings) Id of the networks in which the
    79    container is.
    80  
    81  <a id="ports"></a>
    82  ### Ports
    83  
    84  `ports` is a block within the configuration that can be repeated to specify
    85  the port mappings of the container. Each `ports` block supports
    86  the following:
    87  
    88  * `internal` - (Required, int) Port within the container.
    89  * `external` - (Required, int) Port exposed out of the container.
    90  * `ip` - (Optional, string) IP address/mask that can access this port.
    91  * `protocol` - (Optional, string) Protocol that can be used over this port,
    92    defaults to TCP.
    93  
    94  <a id="extra_hosts"></a>
    95  ### Extra Hosts
    96  
    97  `host_entry` is a block within the configuration that can be repeated to specify
    98  the extra host mappings for the container. Each `host_entry` block supports
    99  the following:
   100  
   101  * `host` - (Required, int) Hostname to add.
   102  * `ip` - (Required, int) IP address this hostname should resolve to..
   103  
   104  This is equivalent to using the `--add-host` option when using the `run`
   105  command of the Docker CLI.
   106  
   107  <a id="volumes"></a>
   108  ### Volumes
   109  
   110  `volumes` is a block within the configuration that can be repeated to specify
   111  the volumes attached to a container. Each `volumes` block supports
   112  the following:
   113  
   114  * `from_container` - (Optional, string) The container where the volume is
   115    coming from.
   116  * `host_path` - (Optional, string) The path on the host where the volume
   117    is coming from.
   118  * `volume_name` - (Optional, string) The name of the docker volume which
   119    should be mounted.
   120  * `container_path` - (Optional, string) The path in the container where the
   121    volume will be mounted.
   122  * `read_only` - (Optional, bool) If true, this volume will be readonly.
   123    Defaults to false.
   124  
   125  One of `from_container`, `host_path` or `volume_name` must be set.
   126  
   127  ## Attributes Reference
   128  
   129  The following attributes are exported:
   130  
   131   * `ip_address` - The IP address of the container as read from its
   132     NetworkSettings.
   133   * `ip_prefix_length` - The IP prefix length of the container as read from its
   134     NetworkSettings.
   135   * `gateway` - The network gateway of the container as read from its
   136     NetworkSettings.
   137   * `bridge` - The network bridge of the container as read from its
   138     NetworkSettings.