terraform-provider-docker/docs/resources/image.md
2021-05-16 15:44:59 +02:00

97 lines
2.6 KiB
Markdown

---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "docker_image Resource - terraform-provider-docker"
subcategory: ""
description: |-
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 i conjunction with [docker_registry_image](/docs/providers/docker/d/registry_image.html data source to update the pull_triggers field.
---
# docker_image (Resource)
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 i conjunction with [`docker_registry_image`](/docs/providers/docker/d/registry_image.html data source to update the `pull_triggers` field.
## Example Usage
```terraform
# Find the latest Ubuntu precise image.
resource "docker_image" "ubuntu" {
name = "ubuntu:precise"
}
# Access it somewhere else with ${docker_image.ubuntu.latest}
# image "zoo" and "zoo:develop" are built
resource "docker_image" "zoo" {
name = "zoo"
build {
path = "."
tag = ["zoo:develop"]
build_arg = {
foo : "zoo"
}
label = {
author : "zoo"
}
}
}
# 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]
}
```
<!-- schema generated by tfplugindocs -->
## Schema
### Required
- **name** (String)
### Optional
- **build** (Block Set, Max: 1) (see [below for nested schema](#nestedblock--build))
- **force_remove** (Boolean) Force remove the image when the resource is destroyed
- **id** (String) The ID of this resource.
- **keep_locally** (Boolean)
- **pull_trigger** (String, Deprecated)
- **pull_triggers** (Set of String)
### Read-Only
- **latest** (String)
- **output** (String)
<a id="nestedblock--build"></a>
### Nested Schema for `build`
Required:
- **path** (String) Context path
Optional:
- **build_arg** (Map of String) Set build-time variables
- **dockerfile** (String) Name of the Dockerfile (Default is 'PATH/Dockerfile')
- **force_remove** (Boolean) Always remove intermediate containers
- **label** (Map of String) Set metadata for an image
- **no_cache** (Boolean) Do not use cache when building the image
- **remove** (Boolean) Remove intermediate containers after a successful build (default true)
- **tag** (List of String) Name and optionally a tag in the 'name:tag' format
- **target** (String) Set the target build stage to build
## Import
Import is supported using the following syntax:
```shell
#!/bin/bash
# TODO
```