terraform-provider-docker/templates/resources/image.md.tmpl
Martin b9181a75e4
feat: Implement using of buildx for docker_image (#717)
* feat: Implement using of buildx for docker_image

* fix: secrets in docker_image

* fix: fmt issues

* test: Add test for build_log_file

* chore: Disable flaky test and update goreleaser to exclude not possible build

* feat: Small refactoring and documentation improvements
2025-05-06 22:21:09 +02:00

53 lines
2.3 KiB
Cheetah

---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "{{.Type}} {{.Name}} - {{.ProviderName}}"
subcategory: ""
description: |-
{{ .Description | plainmarkdown | trimspace | prefixlines " " }}
---
<!-- Bug: Type and Name are switched -->
# {{.Type}} ({{.Name}})
{{ .Description | trimspace }}
## Example Usage
### Basic
Finds and downloads the latest `ubuntu:precise` image but does not check
for further updates of the image
{{tffile "examples/resources/docker_image/resource.tf"}}
### Dynamic updates
To be able to update an image dynamically when the `sha256` sum changes,
you need to use it in combination with `docker_registry_image` as follows:
{{tffile "examples/resources/docker_image/resource-dynamic.tf"}}
### Build
You can also use the resource to build an image. By default the build block is using the old legacy docker build. In order to use a buildx builder, please read the section below
-> **Note**: The default timeout for the building is 20 minutes. If you need to increase this, you can use [operation timeouts](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts).
In this case the image "zoo" and "zoo:develop" are built.
The `context` and `dockerfile` arguments are relative to the local Terraform process (`path.cwd`).
There is no need to copy the files to remote hosts before creating the resource.
{{tffile "examples/resources/docker_image/resource-build.tf"}}
You can use the `triggers` argument to specify when the image should be rebuild. This is for example helpful when you want to rebuild the docker image whenever the source code changes.
{{tffile "examples/resources/docker_image/resource-build-triggers.tf"}}
### Buildx
-> **Note**: The buildx feature is currently in preview and may have some quirks. Known issues: Setting `ulimits` will not work.
The `build` argument uses the legacy docker builder. If you want to use a buildx builder, you need to set the `builder` argument. For the default buildx builder, you can set the `builder` argument to `default`. For a custom buildx builder, you can set the `builder` argument to the name of the builder. You can find the name of the builder by running `docker buildx ls`.
The single platform build result is automatically loaded to `docker images`.
{{ .SchemaMarkdown | trimspace }}