mirror of
https://github.com/kreuzwerker/terraform-provider-docker.git
synced 2025-12-18 23:06:10 -05:00
docs: Consolidated update of docs from several PRs (#691)
Contains the changes of the following PRs https://github.com/kreuzwerker/terraform-provider-docker/pull/576 @triggerNZ https://github.com/kreuzwerker/terraform-provider-docker/pull/536 @Tyonar https://github.com/kreuzwerker/terraform-provider-docker/pull/539 @matthew-palmer https://github.com/kreuzwerker/terraform-provider-docker/pull/541 @siddharthab https://github.com/kreuzwerker/terraform-provider-docker/pull/546 @akeamc https://github.com/kreuzwerker/terraform-provider-docker/pull/549 @manju-rn https://github.com/kreuzwerker/terraform-provider-docker/pull/665 @tparikka https://github.com/kreuzwerker/terraform-provider-docker/pull/559 @tk3fftk
This commit is contained in:
parent
4a46383d4c
commit
50afa9f1f5
6 changed files with 19 additions and 15 deletions
|
|
@ -38,7 +38,7 @@ resource "docker_image" "ubuntu" {
|
|||
- `attach` (Boolean) If `true` attach to the container after its creation and waits the end of its execution. Defaults to `false`.
|
||||
- `capabilities` (Block Set, Max: 1) Add or drop certrain linux capabilities. (see [below for nested schema](#nestedblock--capabilities))
|
||||
- `cgroupns_mode` (String) Cgroup namespace mode to use for the container. Possible values are: `private`, `host`.
|
||||
- `command` (List of String) The command to use to start the container. For example, to run `/usr/bin/myprogram -f baz.conf` set the command to be `["/usr/bin/myprogram","-f","baz.con"]`.
|
||||
- `command` (List of String) The command to use to start the container. For example, to run `/usr/bin/myprogram -f baz.conf` set the command to be `["/usr/bin/myprogram","-f","baz.conf"]`.
|
||||
- `container_read_refresh_timeout_milliseconds` (Number) The total number of milliseconds to wait for the container to reach status 'running'
|
||||
- `cpu_set` (String) A comma-separated list or hyphen-separated range of CPUs a container can use, e.g. `0-1`.
|
||||
- `cpu_shares` (Number) CPU shares (relative weight) for the container.
|
||||
|
|
@ -49,7 +49,7 @@ resource "docker_image" "ubuntu" {
|
|||
- `dns_opts` (Set of String) DNS options used by the DNS provider(s), see `resolv.conf` documentation for valid list of options.
|
||||
- `dns_search` (Set of String) DNS search domains that are used when bare unqualified hostnames are used inside of the container.
|
||||
- `domainname` (String) Domain name of the container.
|
||||
- `entrypoint` (List of String) The command to use as the Entrypoint for the container. The Entrypoint allows you to configure a container to run as an executable. For example, to run `/usr/bin/myprogram` when starting a container, set the entrypoint to be `"/usr/bin/myprogra"]`.
|
||||
- `entrypoint` (List of String) The command to use as the Entrypoint for the container. The Entrypoint allows you to configure a container to run as an executable. For example, to run `/usr/bin/myprogram` when starting a container, set the entrypoint to be `"/usr/bin/myprogram"]`.
|
||||
- `env` (Set of String) Environment variables to set in the form of `KEY=VALUE`, e.g. `DEBUG=0`
|
||||
- `gpus` (String) GPU devices to add to the container. Currently, only the value `all` is supported. Passing any other value will result in unexpected behavior.
|
||||
- `group_add` (Set of String) Additional groups for the container user
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@ page_title: "Resource docker_image - 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 in conjunction with dockerregistryimage registry_image.md data source to update the pull_triggers field.
|
||||
This resource will not pull new layers of the image automatically unless used in conjunction with dockerregistryimage ../data-sources/registry_image.md data source to update the pull_triggers field.
|
||||
---
|
||||
<!-- Bug: Type and Name are switched -->
|
||||
# Resource (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](registry_image.md) data source to update the `pull_triggers` field.
|
||||
This resource will *not* pull new layers of the image automatically unless used in conjunction with [docker_registry_image](../data-sources/registry_image.md) data source to update the `pull_triggers` field.
|
||||
|
||||
## Example Usage
|
||||
|
||||
|
|
@ -45,6 +45,8 @@ resource "docker_image" "ubuntu" {
|
|||
|
||||
You can also use the resource to build an image.
|
||||
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.
|
||||
|
||||
```terraform
|
||||
resource "docker_image" "zoo" {
|
||||
|
|
@ -71,7 +73,7 @@ resource "docker_image" "zoo" {
|
|||
context = "."
|
||||
}
|
||||
triggers = {
|
||||
dir_sha1 = sha1(join("", [for f in fileset(path.module, "src/*") : filesha1(f)]))
|
||||
dir_sha1 = sha1(join("", [for f in fileset(path.module, "src/**") : filesha1(f)]))
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
@ -85,7 +87,7 @@ resource "docker_image" "zoo" {
|
|||
|
||||
### Optional
|
||||
|
||||
- `build` (Block Set, Max: 1) Configuration to build an image. Please see [docker build command reference](https://docs.docker.com/engine/reference/commandline/build/#options) too. (see [below for nested schema](#nestedblock--build))
|
||||
- `build` (Block Set, Max: 1) Configuration to build an image. Requires the `Use containerd for pulling and storing images` option to be disabled in the Docker Host(https://github.com/kreuzwerker/terraform-provider-docker/issues/534). Please see [docker build command reference](https://docs.docker.com/engine/reference/commandline/build/#options) too. (see [below for nested schema](#nestedblock--build))
|
||||
- `force_remove` (Boolean) If true, then the image is removed forcibly when the resource is destroyed.
|
||||
- `keep_locally` (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.
|
||||
- `platform` (String) The platform to use when pulling the image. Defaults to the platform of the current machine.
|
||||
|
|
@ -96,14 +98,14 @@ resource "docker_image" "zoo" {
|
|||
|
||||
- `id` (String) Unique identifier for this resource. This is not the image ID, but the ID of the resource in the Terraform state. This is used to identify the resource in the Terraform state. To reference the correct image ID, use the `image_id` attribute.
|
||||
- `image_id` (String) The ID of the image (as seen when executing `docker inspect` on the image). Can be used to reference the image via its ID in other resources.
|
||||
- `repo_digest` (String) The image sha256 digest in the form of `repo[:tag]@sha256:<hash>`.
|
||||
- `repo_digest` (String) The image sha256 digest in the form of `repo[:tag]@sha256:<hash>`. This may not be populated when building an image, because it is read from the local Docker client and so may be available only when the image was either pulled from the repo or pushed to the repo (perhaps using `docker_registry_image`) in a previous run.
|
||||
|
||||
<a id="nestedblock--build"></a>
|
||||
### Nested Schema for `build`
|
||||
|
||||
Required:
|
||||
|
||||
- `context` (String) Value to specify the build context. Currently, only a `PATH` context is supported. You can use the helper function '${path.cwd}/context-dir'. Please see https://docs.docker.com/build/building/context/ for more information about build contexts.
|
||||
- `context` (String) Value to specify the build context. Currently, only a `PATH` context is supported. You can use the helper function '${path.cwd}/context-dir'. This always refers to the local working directory, even when building images on remote hosts. Please see https://docs.docker.com/build/building/context/ for more information about build contexts.
|
||||
|
||||
Optional:
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,6 @@ resource "docker_image" "zoo" {
|
|||
context = "."
|
||||
}
|
||||
triggers = {
|
||||
dir_sha1 = sha1(join("", [for f in fileset(path.module, "src/*") : filesha1(f)]))
|
||||
dir_sha1 = sha1(join("", [for f in fileset(path.module, "src/**") : filesha1(f)]))
|
||||
}
|
||||
}
|
||||
|
|
@ -153,7 +153,7 @@ func resourceDockerContainer() *schema.Resource {
|
|||
|
||||
"command": {
|
||||
Type: schema.TypeList,
|
||||
Description: "The command to use to start the container. For example, to run `/usr/bin/myprogram -f baz.conf` set the command to be `[\"/usr/bin/myprogram\",\"-f\",\"baz.con\"]`.",
|
||||
Description: "The command to use to start the container. For example, to run `/usr/bin/myprogram -f baz.conf` set the command to be `[\"/usr/bin/myprogram\",\"-f\",\"baz.conf\"]`.",
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Computed: true,
|
||||
|
|
@ -162,7 +162,7 @@ func resourceDockerContainer() *schema.Resource {
|
|||
|
||||
"entrypoint": {
|
||||
Type: schema.TypeList,
|
||||
Description: "The command to use as the Entrypoint for the container. The Entrypoint allows you to configure a container to run as an executable. For example, to run `/usr/bin/myprogram` when starting a container, set the entrypoint to be `\"/usr/bin/myprogra\"]`.",
|
||||
Description: "The command to use as the Entrypoint for the container. The Entrypoint allows you to configure a container to run as an executable. For example, to run `/usr/bin/myprogram` when starting a container, set the entrypoint to be `\"/usr/bin/myprogram\"]`.",
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Computed: true,
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
func resourceDockerImage() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
Description: "Pulls a Docker image to a given Docker host from a Docker Registry.\n This resource will *not* pull new layers of the image automatically unless used in conjunction with [docker_registry_image](registry_image.md) data source to update the `pull_triggers` field.",
|
||||
Description: "Pulls a Docker image to a given Docker host from a Docker Registry.\n This resource will *not* pull new layers of the image automatically unless used in conjunction with [docker_registry_image](../data-sources/registry_image.md) data source to update the `pull_triggers` field.",
|
||||
|
||||
CreateContext: resourceDockerImageCreate,
|
||||
ReadContext: resourceDockerImageRead,
|
||||
|
|
@ -34,7 +34,7 @@ func resourceDockerImage() *schema.Resource {
|
|||
|
||||
"repo_digest": {
|
||||
Type: schema.TypeString,
|
||||
Description: "The image sha256 digest in the form of `repo[:tag]@sha256:<hash>`.",
|
||||
Description: "The image sha256 digest in the form of `repo[:tag]@sha256:<hash>`. This may not be populated when building an image, because it is read from the local Docker client and so may be available only when the image was either pulled from the repo or pushed to the repo (perhaps using `docker_registry_image`) in a previous run.",
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ func resourceDockerImage() *schema.Resource {
|
|||
|
||||
"build": {
|
||||
Type: schema.TypeSet,
|
||||
Description: "Configuration to build an image. Please see [docker build command reference](https://docs.docker.com/engine/reference/commandline/build/#options) too.",
|
||||
Description: "Configuration to build an image. Requires the `Use containerd for pulling and storing images` option to be disabled in the Docker Host(https://github.com/kreuzwerker/terraform-provider-docker/issues/534). Please see [docker build command reference](https://docs.docker.com/engine/reference/commandline/build/#options) too.",
|
||||
Optional: true,
|
||||
MaxItems: 1,
|
||||
ConflictsWith: []string{"pull_triggers"},
|
||||
|
|
@ -310,7 +310,7 @@ func resourceDockerImage() *schema.Resource {
|
|||
},
|
||||
"context": {
|
||||
Type: schema.TypeString,
|
||||
Description: "Value to specify the build context. Currently, only a `PATH` context is supported. You can use the helper function '${path.cwd}/context-dir'. Please see https://docs.docker.com/build/building/context/ for more information about build contexts.",
|
||||
Description: "Value to specify the build context. Currently, only a `PATH` context is supported. You can use the helper function '${path.cwd}/context-dir'. This always refers to the local working directory, even when building images on remote hosts. Please see https://docs.docker.com/build/building/context/ for more information about build contexts.",
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ you need to use it in combination with `docker_registry_image` as follows:
|
|||
|
||||
You can also use the resource to build an image.
|
||||
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"}}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue