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