mirror of
https://github.com/kreuzwerker/terraform-provider-docker.git
synced 2026-02-02 11:49:29 -05:00
* feat: Implement docker cluster volume * fix: linter findings * fix: Make cluster attribute updateable
3.2 KiB
3.2 KiB
| page_title | subcategory | description |
|---|---|---|
| Resource docker_volume - terraform-provider-docker | Creates and destroys a volume in Docker. This can be used alongside docker_container container.md to prepare volumes that can be shared across containers. |
Resource (docker_volume)
Creates and destroys a volume in Docker. This can be used alongside docker_container to prepare volumes that can be shared across containers.
Example Usage
resource "docker_volume" "shared_volume" {
name = "shared_volume"
}
Schema
Optional
cluster(Block List, Max: 1) Cluster-specific options for volume creation. Only works if the Docker daemon is running in swarm mode and is the swarm manager. (see below for nested schema)driver(String) Driver type for the volume. Defaults tolocal.driver_opts(Map of String) Options specific to the driver.labels(Block Set) User-defined key/value metadata (see below for nested schema)name(String) The name of the Docker volume (will be generated if not provided).
Read-Only
id(String) The ID of this resource.mountpoint(String) The mountpoint of the volume.
Nested Schema for cluster
Optional:
availability(String) Availability of the volume. Can beactive(default),pause, ordrain.group(String) Cluster Volume grouplimit_bytes(String) Minimum size of the Cluster Volume in human readable memory bytes (like 128MiB, 2GiB, etc). Must be in format of KiB, MiB, Gib, Tib or PiB.required_bytes(String) Maximum size of the Cluster Volume in human readable memory bytes (like 128MiB, 2GiB, etc). Must be in format of KiB, MiB, Gib, Tib or PiB.scope(String) The scope of the volume. Can besingle(default) ormulti.sharing(String) The sharing mode. Can benone(default),readonly,onewriterorall.topology_preferred(String) A topology that the Cluster Volume would be preferred intopology_required(String) A topology that the Cluster Volume must be accessible fromtype(String) Cluster Volume access type. Can bemountorblock(default).
Read-Only:
id(String) The ID of the cluster volume.
Nested Schema for labels
Required:
label(String) Name of the labelvalue(String) Value of the label
Import
Import is supported using the following syntax by providing the id:
#!/bin/bash
terraform import docker_volume.foo id
Example
Assuming you created a volume as follows
#!/bin/bash
docker volume create
# prints the long ID
524b0457aa2a87dd2b75c74c3e4e53f406974249e63ab3ed9bf21e5644f9dc7d
you provide the definition for the resource as follows
resource "docker_volume" "foo" {
name = "524b0457aa2a87dd2b75c74c3e4e53f406974249e63ab3ed9bf21e5644f9dc7d"
}
then the import command is as follows
#!/bin/bash
terraform import docker_volume.foo 524b0457aa2a87dd2b75c74c3e4e53f406974249e63ab3ed9bf21e5644f9dc7d