Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Prepare v3 release #503

Merged
merged 9 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions docs/resources/container.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ resource "docker_image" "ubuntu" {
- `init` (Boolean) Configured whether an init process should be injected for this container. If unset this will default to the `dockerd` defaults.
- `ipc_mode` (String) IPC sharing mode for the container. Possible values are: `none`, `private`, `shareable`, `container:<name|id>` or `host`.
- `labels` (Block Set) User-defined key/value metadata (see [below for nested schema](#nestedblock--labels))
- `links` (Set of String, Deprecated) Set of links for link based connectivity between containers that are running on the same host.
- `log_driver` (String) The logging driver to use for the container.
- `log_opts` (Map of String) Key/value pairs to use as options for the logging driver.
- `logs` (Boolean) Save the container logs (`attach` must be enabled). Defaults to `false`.
Expand All @@ -67,9 +66,7 @@ resource "docker_image" "ubuntu" {
- `memory_swap` (Number) The total memory limit (memory + swap) for the container in MBs. This setting may compute to `-1` after `terraform apply` if the target host doesn't support memory swap, when that is the case docker will use a soft limitation.
- `mounts` (Block Set) Specification for mounts to be added to containers created as part of the service. (see [below for nested schema](#nestedblock--mounts))
- `must_run` (Boolean) If `true`, then the Docker container will be kept running. If `false`, then as long as the container exists, Terraform assumes it is successful. Defaults to `true`.
- `network_alias` (Set of String, Deprecated) Set an alias for the container in all specified networks
- `network_mode` (String) Network mode of the container.
- `networks` (Set of String, Deprecated) ID of the networks in which the container is.
- `networks_advanced` (Block Set) The networks the container is attached to (see [below for nested schema](#nestedblock--networks_advanced))
- `pid_mode` (String) he PID (Process) Namespace mode for the container. Either `container:<name|id>` or `host`.
- `ports` (Block List) Publish a container's port(s) to the host. (see [below for nested schema](#nestedblock--ports))
Expand Down Expand Up @@ -104,10 +101,7 @@ resource "docker_image" "ubuntu" {
- `bridge` (String) The network bridge of the container as read from its NetworkSettings.
- `container_logs` (String) The logs of the container if its execution is done (`attach` must be disabled).
- `exit_code` (Number) The exit code of the container if its execution is done (`must_run` must be disabled).
- `gateway` (String, Deprecated) The network gateway of the container.
- `id` (String) The ID of this resource.
- `ip_address` (String, Deprecated) The IP address of the container.
- `ip_prefix_length` (Number, Deprecated) The IP prefix length of the container.
- `network_data` (List of Object) The data of the networks the container is connected to. (see [below for nested schema](#nestedatt--network_data))

<a id="nestedblock--capabilities"></a>
Expand Down
15 changes: 7 additions & 8 deletions docs/resources/image.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ In this case the image "zoo" and "zoo:develop" are built.
resource "docker_image" "zoo" {
name = "zoo"
build {
path = "."
tag = ["zoo:develop"]
context = "."
tag = ["zoo:develop"]
build_arg = {
foo : "zoo"
}
Expand All @@ -68,7 +68,7 @@ You can use the `triggers` argument to specify when the image should be rebuild.
resource "docker_image" "zoo" {
name = "zoo"
build {
path = "."
context = "."
}
triggers = {
dir_sha1 = sha1(join("", [for f in fileset(path.module, "src/*") : filesha1(f)]))
Expand All @@ -89,21 +89,22 @@ resource "docker_image" "zoo" {
- `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.
- `pull_trigger` (String, Deprecated) A value which cause an image pull when changed
- `pull_triggers` (Set of String) 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-sources/registry_image.md).
- `triggers` (Map of String) A map of arbitrary strings that, when changed, will force the `docker_image` resource to be replaced. This can be used to rebuild an image when contents of source code folders change

### Read-Only

- `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.
- `latest` (String, Deprecated) The ID of the image in the form of `sha256:<hash>` image digest. Do not confuse it with the default `latest` tag.
- `output` (String, Deprecated)
- `repo_digest` (String) The image sha256 digest in the form of `repo[:tag]@sha256:<hash>`.

<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.

Optional:

- `auth_config` (Block List) The configuration for the authentication (see [below for nested schema](#nestedblock--build--auth_config))
Expand All @@ -112,7 +113,6 @@ Optional:
- `build_id` (String) BuildID is an optional identifier that can be passed together with the build request. The same identifier can be used to gracefully cancel the build with the cancel request.
- `cache_from` (List of String) Images to consider as cache sources
- `cgroup_parent` (String) Optional parent cgroup for the container
- `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.
- `cpu_period` (Number) The length of a CPU period in microseconds
- `cpu_quota` (Number) Microseconds of CPU time that the container can get in a CPU period
- `cpu_set_cpus` (String) CPUs in which to allow execution (e.g., `0-3`, `0`, `1`)
Expand All @@ -128,7 +128,6 @@ Optional:
- `memory_swap` (Number) Total memory (memory + swap), -1 to enable unlimited swap
- `network_mode` (String) Set the networking mode for the RUN instructions during build
- `no_cache` (Boolean) Do not use the cache when building the image
- `path` (String, Deprecated) Context path
- `platform` (String) Set platform if server is multi-platform capable
- `pull_parent` (Boolean) Attempt to pull the image even if an older image exists locally
- `remote_context` (String) A Git repository URI or HTTP/HTTPS context URI
Expand Down
83 changes: 9 additions & 74 deletions docs/resources/registry_image.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,25 @@
page_title: "Resource docker_registry_image - terraform-provider-docker"
subcategory: ""
description: |-
Manages the lifecycle of docker image/tag in a registry means it can store one or more version of specific docker images and identified by their tags.
Manages the lifecycle of docker image in a registry. You can upload images to a registry (= docker push) and also delete them again
---
<!-- Bug: Type and Name are switched -->
# Resource (docker_registry_image)

Manages the lifecycle of docker image/tag in a registry means it can store one or more version of specific docker images and identified by their tags.
Manages the lifecycle of docker image in a registry. You can upload images to a registry (= `docker push`) and also delete them again

## Example Usage

To be able to update an image itself when an updated image arrives.
Build an image with the `docker_image` resource and then push it to a registry:

```terraform
resource "docker_registry_image" "helloworld" {
name = "helloworld:1.0"
name = docker_image.image.name
keep_remotely = true
}

resource "docker_image" "image" {
name = "registry.com/somename:1.0"
build {
context = "${path.cwd}/absolutePathToContextFolder"
}
Expand All @@ -33,80 +37,11 @@ resource "docker_registry_image" "helloworld" {

### Optional

- `build` (Block List, Max: 1, Deprecated) This field is deprecated. Use the `build` block of the `docker_image` resource instead. This field will be removed in the next major release. (see [below for nested schema](#nestedblock--build))
- `insecure_skip_verify` (Boolean) If `true`, the verification of TLS certificates of the server/registry is disabled. Defaults to `false`
- `keep_remotely` (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 registry on destroy operation. Defaults to `false`
- `triggers` (Map of String) A map of arbitrary strings that, when changed, will force the `docker_registry_image` resource to be replaced. This can be used to repush a local image

### Read-Only

- `id` (String) The ID of this resource.
- `sha256_digest` (String) The sha256 digest of the image.

<a id="nestedblock--build"></a>
### Nested Schema for `build`

Required:

- `context` (String) The absolute path to the context folder. You can use the helper function '${path.cwd}/context-dir'.

Optional:

- `auth_config` (Block List) The configuration for the authentication (see [below for nested schema](#nestedblock--build--auth_config))
- `build_args` (Map of String) Pairs for build-time variables in the form TODO
- `build_id` (String) BuildID is an optional identifier that can be passed together with the build request. The same identifier can be used to gracefully cancel the build with the cancel request.
- `cache_from` (List of String) Images to consider as cache sources
- `cgroup_parent` (String) Optional parent cgroup for the container
- `cpu_period` (Number) The length of a CPU period in microseconds
- `cpu_quota` (Number) Microseconds of CPU time that the container can get in a CPU period
- `cpu_set_cpus` (String) CPUs in which to allow execution (e.g., `0-3`, `0`, `1`)
- `cpu_set_mems` (String) MEMs in which to allow execution (`0-3`, `0`, `1`)
- `cpu_shares` (Number) CPU shares (relative weight)
- `dockerfile` (String) Dockerfile file. Defaults to `Dockerfile`
- `extra_hosts` (List of String) A list of hostnames/IP mappings to add to the container’s /etc/hosts file. Specified in the form ["hostname:IP"]
- `force_remove` (Boolean) Always remove intermediate containers
- `isolation` (String) Isolation represents the isolation technology of a container. The supported values are
- `labels` (Map of String) User-defined key/value metadata
- `memory` (Number) Set memory limit for build
- `memory_swap` (Number) Total memory (memory + swap), -1 to enable unlimited swap
- `network_mode` (String) Set the networking mode for the RUN instructions during build
- `no_cache` (Boolean) Do not use the cache when building the image
- `platform` (String) Set platform if server is multi-platform capable
- `pull_parent` (Boolean) Attempt to pull the image even if an older image exists locally
- `remote_context` (String) A Git repository URI or HTTP/HTTPS context URI
- `remove` (Boolean) Remove intermediate containers after a successful build (default behavior)
- `security_opt` (List of String) The security options
- `session_id` (String) Set an ID for the build session
- `shm_size` (Number) Size of /dev/shm in bytes. The size must be greater than 0
- `squash` (Boolean) If true the new layers are squashed into a new image with a single new layer
- `suppress_output` (Boolean) Suppress the build output and print image ID on success
- `target` (String) Set the target build stage to build
- `ulimit` (Block List) Configuration for ulimits (see [below for nested schema](#nestedblock--build--ulimit))
- `version` (String) Version of the underlying builder to use

<a id="nestedblock--build--auth_config"></a>
### Nested Schema for `build.auth_config`

Required:

- `host_name` (String) hostname of the registry

Optional:

- `auth` (String) the auth token
- `email` (String) the user emal
- `identity_token` (String) the identity token
- `password` (String) the registry password
- `registry_token` (String) the registry token
- `server_address` (String) the server address
- `user_name` (String) the registry user name


<a id="nestedblock--build--ulimit"></a>
### Nested Schema for `build.ulimit`

Required:

- `hard` (Number) soft limit
- `name` (String) type of ulimit, e.g. `nofile`
- `soft` (Number) hard limit
- `sha256_digest` (String) The sha256 digest of the image.
1 change: 0 additions & 1 deletion docs/resources/service.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ Optional:

- `force_update` (Number) A counter that triggers an update even if no relevant parameters have been changed. See the [spec](https://github.com/docker/swarmkit/blob/master/api/specs.proto#L126).
- `log_driver` (Block List, Max: 1) Specifies the log driver to use for tasks created from this spec. If not present, the default one for the swarm will be used, finally falling back to the engine default if not specified (see [below for nested schema](#nestedblock--task_spec--log_driver))
- `networks` (Set of String, Deprecated) Ids of the networks in which the container will be put in
- `networks_advanced` (Block Set) The networks the container is attached to (see [below for nested schema](#nestedblock--task_spec--networks_advanced))
- `placement` (Block List, Max: 1) The placement preferences (see [below for nested schema](#nestedblock--task_spec--placement))
- `resources` (Block List, Max: 1) Resource requirements which apply to each individual container created as part of the service (see [below for nested schema](#nestedblock--task_spec--resources))
Expand Down
7 changes: 4 additions & 3 deletions docs/v2_v3_migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

This guide is intended to help you migrate from V2 to V3 of the `terraform-provider-docker`.

The in the past minor versions there were many new attributes and older attributes are deprecated.
The in the past minor versions there were many new attributes and older attributes are deprecated.

This will give you an overview over which attributes are deprecated and which attributes you should use instead.

## `docker_container`


Deprecated attributes:

* `links`: The --link flag is a legacy feature of Docker and will be removed (https://docs.docker.com/network/links/)
* `ip_address`, `ip_prefix_length`, `gateway`: Use the `network_data` block instead
* `network_alias`, `networks`: Use the `networks_addvanced` block instead
Expand Down Expand Up @@ -37,11 +38,11 @@ resource "docker_image" "foo_image" {
provider = "docker.private"
name = "somename"
build {
// your build params
// your build params
}
}

resource "docker_registry_image" "foo" {
name = docker_image.foo_image.name
name = docker_image.foo_image.name
}
```
2 changes: 1 addition & 1 deletion examples/resources/docker_image/resource-build-triggers.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
resource "docker_image" "zoo" {
name = "zoo"
build {
path = "."
context = "."
}
triggers = {
dir_sha1 = sha1(join("", [for f in fileset(path.module, "src/*") : filesha1(f)]))
Expand Down
4 changes: 2 additions & 2 deletions examples/resources/docker_image/resource-build.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
resource "docker_image" "zoo" {
name = "zoo"
build {
path = "."
tag = ["zoo:develop"]
context = "."
tag = ["zoo:develop"]
build_arg = {
foo : "zoo"
}
Expand Down
8 changes: 6 additions & 2 deletions examples/resources/docker_registry_image/resource.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
resource "docker_registry_image" "helloworld" {
name = "helloworld:1.0"
name = docker_image.image.name
keep_remotely = true
}

resource "docker_image" "image" {
name = "registry.com/somename:1.0"
build {
context = "${path.cwd}/absolutePathToContextFolder"
}
}
}
54 changes: 0 additions & 54 deletions internal/provider/resource_docker_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,37 +568,6 @@ func resourceDockerContainer() *schema.Resource {
Set: schema.HashString,
},

"links": {
Type: schema.TypeSet,
Description: "Set of links for link based connectivity between containers that are running on the same host.",
Optional: true,
ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: schema.HashString,
Deprecated: "The --link flag is a legacy feature of Docker. It may eventually be removed.",
},

"ip_address": {
Type: schema.TypeString,
Description: "The IP address of the container.",
Computed: true,
Deprecated: "Use `network_data` instead. The IP address of the container's first network it.",
},

"ip_prefix_length": {
Type: schema.TypeInt,
Description: "The IP prefix length of the container.",
Computed: true,
Deprecated: "Use `network_data` instead. The IP prefix length of the container as read from its NetworkSettings.",
},

"gateway": {
Type: schema.TypeString,
Description: "The network gateway of the container.",
Computed: true,
Deprecated: "Use `network_data` instead. The network gateway of the container as read from its NetworkSettings.",
},

"bridge": {
Type: schema.TypeString,
Description: "The network bridge of the container as read from its NetworkSettings.",
Expand All @@ -620,19 +589,16 @@ func resourceDockerContainer() *schema.Resource {
Type: schema.TypeString,
Description: "The IP address of the container.",
Computed: true,
Deprecated: "Use `network_data` instead. The IP address of the container's first network it.",
},
"ip_prefix_length": {
Type: schema.TypeInt,
Description: "The IP prefix length of the container.",
Computed: true,
Deprecated: "Use `network_data` instead. The IP prefix length of the container as read from its NetworkSettings.",
},
"gateway": {
Type: schema.TypeString,
Description: "The network gateway of the container.",
Computed: true,
Deprecated: "Use `network_data` instead. The network gateway of the container as read from its NetworkSettings.",
},
"global_ipv6_address": {
Type: schema.TypeString,
Expand Down Expand Up @@ -756,16 +722,6 @@ func resourceDockerContainer() *schema.Resource {
ForceNew: true,
},

"network_alias": {
Type: schema.TypeSet,
Description: "Set an alias for the container in all specified networks",
Optional: true,
ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: schema.HashString,
Deprecated: "Use networks_advanced instead. Will be removed in v3.0.0",
},

"network_mode": {
Type: schema.TypeString,
Description: "Network mode of the container.",
Expand All @@ -783,16 +739,6 @@ func resourceDockerContainer() *schema.Resource {
},
},

"networks": {
Type: schema.TypeSet,
Description: "ID of the networks in which the container is.",
Optional: true,
ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: schema.HashString,
Deprecated: "Use networks_advanced instead. Will be removed in v3.0.0",
},

"networks_advanced": {
Type: schema.TypeSet,
Description: "The networks the container is attached to",
Expand Down
Loading