mirror of
https://github.com/kreuzwerker/terraform-provider-docker.git
synced 2025-12-31 12:10:27 -05:00
2.3 KiB
2.3 KiB
| layout | page_title | sidebar_current | description |
|---|---|---|---|
| docker | Docker: docker_image | docs-docker-resource-image | Pulls a Docker image to a given Docker host. |
docker_image
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
conjunction with docker_registry_image
data source to update the pull_triggers field.
Example Usage
# Find the latest Ubuntu precise image.
resource "docker_image" "ubuntu" {
name = "ubuntu:precise"
}
# Access it somewhere else with ${docker_image.ubuntu.latest}
Dynamic image
data "docker_registry_image" "ubuntu" {
name = "ubuntu:precise"
}
resource "docker_image" "ubuntu" {
name = "${data.docker_registry_image.ubuntu.name}"
pull_triggers = ["${data.docker_registry_image.ubuntu.sha256_digest}"]
}
Argument Reference
The following arguments are supported:
name- (Required, string) The name of the Docker image, including any tags or SHA256 repo digests.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.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 thedocker_registry_imagedata source to trigger an image update.pull_trigger- Deprecated, usepull_triggersinstead.build- (Optional, block) See Build below for details.
Build
Build image.
The build block supports:
path- (Required, string)dockerfile- (Optional, string) default Dockerfiletag- (Optional, list of strings)force_remove- (Optional, boolean)remove- (Optional, boolean) default trueno_cache- (Optional, boolean)target- (Optional, string)build_arg- (Optional, map of strings)label- (Optional, map of strings)
Attributes Reference
The following attributes are exported in addition to the above configuration:
latest(string) - The ID of the image.