mirror of
https://github.com/kreuzwerker/terraform-provider-docker.git
synced 2025-12-21 23:29:59 -05:00
77 lines
2 KiB
Markdown
77 lines
2 KiB
Markdown
|
|
---
|
||
|
|
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||
|
|
page_title: "docker_volume Resource - terraform-provider-docker"
|
||
|
|
subcategory: ""
|
||
|
|
description: |-
|
||
|
|
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.
|
||
|
|
---
|
||
|
|
<!-- Bug: Type and Name are switched -->
|
||
|
|
# docker_volume (Resource)
|
||
|
|
|
||
|
|
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.
|
||
|
|
|
||
|
|
## Example Usage
|
||
|
|
|
||
|
|
```terraform
|
||
|
|
resource "docker_volume" "shared_volume" {
|
||
|
|
name = "shared_volume"
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
<!-- schema generated by tfplugindocs -->
|
||
|
|
## Schema
|
||
|
|
|
||
|
|
### Optional
|
||
|
|
|
||
|
|
- **driver** (String) Driver type for the volume. Defaults to `local`.
|
||
|
|
- **driver_opts** (Map of String) Options specific to the driver.
|
||
|
|
- **id** (String) The ID of this resource.
|
||
|
|
- **labels** (Block Set) User-defined key/value metadata (see [below for nested schema](#nestedblock--labels))
|
||
|
|
- **name** (String) The name of the Docker volume (will be generated if not provided).
|
||
|
|
|
||
|
|
### Read-Only
|
||
|
|
|
||
|
|
- **mountpoint** (String) The mountpoint of the volume.
|
||
|
|
|
||
|
|
<a id="nestedblock--labels"></a>
|
||
|
|
### Nested Schema for `labels`
|
||
|
|
|
||
|
|
Required:
|
||
|
|
|
||
|
|
- **label** (String) Name of the label
|
||
|
|
- **value** (String) Value of the label
|
||
|
|
|
||
|
|
## Import
|
||
|
|
|
||
|
|
Import is supported using the following syntax by providing the `id`:
|
||
|
|
|
||
|
|
```shell
|
||
|
|
#!/bin/bash
|
||
|
|
terraform import docker_volume.foo id
|
||
|
|
```
|
||
|
|
|
||
|
|
### Example
|
||
|
|
|
||
|
|
Assuming you created a `volume` as follows
|
||
|
|
|
||
|
|
```shell
|
||
|
|
#!/bin/bash
|
||
|
|
docker volume create
|
||
|
|
# prints the long ID
|
||
|
|
524b0457aa2a87dd2b75c74c3e4e53f406974249e63ab3ed9bf21e5644f9dc7d
|
||
|
|
```
|
||
|
|
|
||
|
|
you provide the definition for the resource as follows
|
||
|
|
|
||
|
|
```terraform
|
||
|
|
resource "docker_volume" "foo" {
|
||
|
|
name = "524b0457aa2a87dd2b75c74c3e4e53f406974249e63ab3ed9bf21e5644f9dc7d"
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
then the import command is as follows
|
||
|
|
|
||
|
|
```shell
|
||
|
|
#!/bin/bash
|
||
|
|
terraform import docker_volume.foo 524b0457aa2a87dd2b75c74c3e4e53f406974249e63ab3ed9bf21e5644f9dc7d
|
||
|
|
```
|