2015-03-29 04:05:17 +02:00
|
|
|
---
|
|
|
|
layout: "docker"
|
|
|
|
page_title: "Docker: docker_image"
|
|
|
|
sidebar_current: "docs-docker-resource-image"
|
|
|
|
description: |-
|
2016-07-26 18:07:35 +02:00
|
|
|
Pulls a Docker image to a given Docker host.
|
2015-03-29 04:05:17 +02:00
|
|
|
---
|
|
|
|
|
|
|
|
# docker\_image
|
|
|
|
|
2016-07-26 18:07:35 +02:00
|
|
|
-> **Note:** The initial (current) version of this resource can only pull **public** images **from the official Docker Hub Registry**.
|
|
|
|
|
|
|
|
Pulls a Docker image to a given Docker host from a Docker Registry.
|
|
|
|
|
|
|
|
This resource will *not* pull new layers of the image automatically unless used in
|
2016-09-12 08:04:04 +02:00
|
|
|
conjunction with [`docker_registry_image`](/docs/providers/docker/d/registry_image.html)
|
2017-01-03 17:10:39 +01:00
|
|
|
data source to update the `pull_triggers` field.
|
2015-03-29 04:05:17 +02:00
|
|
|
|
|
|
|
## Example Usage
|
|
|
|
|
2017-04-17 12:17:54 +02:00
|
|
|
```hcl
|
2015-03-29 04:05:17 +02:00
|
|
|
# Find the latest Ubuntu precise image.
|
|
|
|
resource "docker_image" "ubuntu" {
|
2017-02-18 23:48:50 +01:00
|
|
|
name = "ubuntu:precise"
|
2015-03-29 04:05:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Access it somewhere else with ${docker_image.ubuntu.latest}
|
2017-02-18 23:48:50 +01:00
|
|
|
|
2015-03-29 04:05:17 +02:00
|
|
|
```
|
|
|
|
|
2016-07-26 18:07:35 +02:00
|
|
|
### Dynamic image
|
|
|
|
|
2017-04-17 12:17:54 +02:00
|
|
|
```hcl
|
2016-07-26 18:07:35 +02:00
|
|
|
data "docker_registry_image" "ubuntu" {
|
2017-02-18 23:48:50 +01:00
|
|
|
name = "ubuntu:precise"
|
2016-07-26 18:07:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "docker_image" "ubuntu" {
|
2017-02-18 23:48:50 +01:00
|
|
|
name = "${data.docker_registry_image.ubuntu.name}"
|
|
|
|
pull_triggers = ["${data.docker_registry_image.ubuntu.sha256_digest}"]
|
2016-07-26 18:07:35 +02:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2015-03-29 04:05:17 +02:00
|
|
|
## Argument Reference
|
|
|
|
|
|
|
|
The following arguments are supported:
|
|
|
|
|
2016-01-30 22:23:35 +01:00
|
|
|
* `name` - (Required, string) The name of the Docker image, including any tags.
|
2016-04-27 18:18:02 +02:00
|
|
|
* `keep_locally` - (Optional, boolean) If true, then the Docker image won't be
|
|
|
|
deleted on destroy operation. If this is false, it will delete the image from
|
|
|
|
the docker local storage on destroy operation.
|
2017-01-03 17:10:39 +01:00
|
|
|
* `pull_triggers` - (Optional, list of strings) List of values which cause an
|
|
|
|
image pull when changed. This is used to store the image digest from the
|
|
|
|
registry when using the `docker_registry_image` [data source](/docs/providers/docker/d/registry_image.html)
|
|
|
|
to trigger an image update.
|
|
|
|
* `pull_trigger` - **Deprecated**, use `pull_triggers` instead.
|
|
|
|
|
2015-03-29 04:05:17 +02:00
|
|
|
|
|
|
|
## Attributes Reference
|
|
|
|
|
|
|
|
The following attributes are exported in addition to the above configuration:
|
|
|
|
|
|
|
|
* `latest` (string) - The ID of the image.
|