mirror of
https://github.com/kreuzwerker/terraform-provider-docker.git
synced 2026-01-07 15:29:37 -05:00
* chore: add tfplugindocs tool
* feat: add tfplugin doc dependency and make target
* chore: apply documentation generation
* docs(contributing): update for documentation generation
* fix: adapt website-lint target to new do folder
* docs(network): update ds descriptions
* docs: add template for index.md
* docs: add network resource generation
* chore(ci): updates paths for website checks
* docs: add plugin data source generation
* docs: add import cmd for network resource
* docs: add plugin resource generation
* feat: outlines remaining resources with example and import cmd
* feat: add descriptions to docs
* chore: add DevSkim ignores and fix capitalized errors
* docs: complete ds registry image
* docs: add container resource generation
* docs: add lables description to missing resources
* docs: remove computed:true from network data
so the list is rendered in the description
* Revert "docs: remove computed:true from network data"
This reverts commit dce9b7a5a2.
* docs: add docker image descriptions to generate the docs
* docs: add docker registry image descriptions to generate the docs
* docs: add docker service descriptions to generate the docs
* docs: add docker volume descriptions to generate the docs
* docs(index): clarifies description
so more docker resources are mentioned
* docs(network): fixes required and read-only attributes
so the ds can only be read by-name
* docs(plugin): clarifies the ds docs attributes
* docs: fix typo registry image ds
* docs(config): clarifies attributes and enhances examples
Provide a long example and import command
* fix(config): make data non-sensitive
Because only secrets data is
* docs(containter): clarifies attributes
and enhances examples with import
* docs(config): fix typo
* docs(image): clarifies attributes and remove import
* docs(network): clarifies attributes and adapts import
* docs(plugin): clarifies attributes and import
* docs(registry_image): clarifies attributes and removes import
* chore(secret): remove typo
* docs(service): clarifies attributes and import
* docs(volume): clarifies attributes and import
* fix: correct md linter rules after doc gen
* docs(volume): regenerated
* docs: add config custom template
* docs: add templates for all resources
* docs(config): templates all sections and examples
for better redability and structure
* docs(config): fix md linter
* docs(container): templates all sections and examples
* docs(image): templates all sections and examples
* docs(image): fix import resource by renaming
* docs(network): templates all sections and examples
* docs(service): templates all sections and examples
* docs(volume): templates all sections and examples
* fix(lint): replace website with doc directory
* fix(ci): link check file extension check
* fix: markdown links
* chore: remove old website folder
* chore: fix website-lint terrafmr dir and pattern
* fix: lint fix target website folder
* fix: website links
* docs(provider): update examples
with templates on auth and certs
* docs(provider): add tf-plugin-docs line
* docs(contributing): split doc generation section
* docs: final brush up for readability and structure
* chore(ci): add website-generation job
to see if files changed and it should run locally again
* chore(ci): remove explicit docker setup
from website lint because it's installed by default
201 lines
No EOL
4.9 KiB
Markdown
201 lines
No EOL
4.9 KiB
Markdown
---
|
|
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
|
layout: ""
|
|
page_title: "Provider: Docker"
|
|
description: |-
|
|
The Docker provider is used to interact with Docker resources, like containers, images, service etc.
|
|
---
|
|
|
|
# Docker Provider
|
|
|
|
The Docker provider is used to interact with Docker containers and images.
|
|
It uses the Docker API to manage the lifecycle of Docker containers. Because
|
|
the Docker provider uses the Docker API, it is immediately compatible not
|
|
only with single server Docker but Swarm and any additional Docker-compatible
|
|
API hosts.
|
|
|
|
Use the navigation to the left to read about the available resources.
|
|
|
|
## Example Usage
|
|
|
|
Terraform 0.13 and later:
|
|
|
|
```terraform
|
|
terraform {
|
|
required_providers {
|
|
docker = {
|
|
source = "kreuzwerker/docker"
|
|
version = "2.11.0"
|
|
}
|
|
}
|
|
}
|
|
|
|
provider "docker" {
|
|
host = "unix:///var/run/docker.sock"
|
|
}
|
|
|
|
# Pulls the image
|
|
resource "docker_image" "ubuntu" {
|
|
name = "ubuntu:latest"
|
|
}
|
|
|
|
# Create a container
|
|
resource "docker_container" "foo" {
|
|
image = docker_image.ubuntu.latest
|
|
name = "foo"
|
|
}
|
|
```
|
|
|
|
Terraform 0.12 and earlier:
|
|
|
|
```terraform
|
|
provider "docker" {
|
|
version = "~> 2.11.0"
|
|
host = "unix:///var/run/docker.sock"
|
|
}
|
|
|
|
# Pulls the image
|
|
resource "docker_image" "ubuntu" {
|
|
name = "ubuntu:latest"
|
|
}
|
|
|
|
# Create a container
|
|
resource "docker_container" "foo" {
|
|
image = docker_image.ubuntu.latest
|
|
name = "foo"
|
|
}
|
|
```
|
|
|
|
-> **Note**
|
|
You can also use the `ssh` protocol to connect to the docker host on a remote machine.
|
|
The configuration would look as follows:
|
|
|
|
```terraform
|
|
terraform {
|
|
required_providers {
|
|
docker = {
|
|
source = "kreuzwerker/docker"
|
|
version = "2.11.0"
|
|
}
|
|
}
|
|
}
|
|
|
|
provider "docker" {
|
|
host = "unix:///var/run/docker.sock"
|
|
}
|
|
|
|
# Pulls the image
|
|
resource "docker_image" "ubuntu" {
|
|
name = "ubuntu:latest"
|
|
}
|
|
|
|
# Create a container
|
|
resource "docker_container" "foo" {
|
|
image = docker_image.ubuntu.latest
|
|
name = "foo"
|
|
}
|
|
```
|
|
|
|
## Registry credentials
|
|
|
|
Registry credentials can be provided on a per-registry basis with the `registry_auth`
|
|
field, passing either a config file or the username/password directly.
|
|
|
|
-> **Note**
|
|
The location of the config file is on the machine terraform runs on, nevertheless if the specified docker host is on another machine.
|
|
|
|
```terraform
|
|
provider "docker" {
|
|
host = "tcp://localhost:2376"
|
|
|
|
registry_auth {
|
|
address = "registry.hub.docker.com"
|
|
config_file = pathexpand("~/.docker/config.json")
|
|
}
|
|
|
|
registry_auth {
|
|
address = "registry.my.company.com"
|
|
config_file_content = var.plain_content_of_config_file
|
|
}
|
|
|
|
registry_auth {
|
|
address = "quay.io:8181"
|
|
username = "someuser"
|
|
password = "somepass"
|
|
}
|
|
}
|
|
|
|
data "docker_registry_image" "quay" {
|
|
name = "myorg/privateimage"
|
|
}
|
|
|
|
data "docker_registry_image" "quay" {
|
|
name = "quay.io:8181/myorg/privateimage"
|
|
}
|
|
```
|
|
|
|
-> **Note**
|
|
When passing in a config file either the corresponding `auth` string of the repository is read or the os specific
|
|
[credential helpers](https://github.com/docker/docker-credential-helpers#available-programs) are
|
|
used to retrieve the authentication credentials.
|
|
|
|
You can still use the environment variables `DOCKER_REGISTRY_USER` and `DOCKER_REGISTRY_PASS`.
|
|
|
|
An example content of the file `~/.docker/config.json` on macOS may look like follows:
|
|
|
|
```json
|
|
{
|
|
"auths": {
|
|
"repo.mycompany:8181": {
|
|
"auth": "dXNlcjpwYXNz="
|
|
},
|
|
"otherrepo.other-company:8181": {}
|
|
},
|
|
"credsStore": "osxkeychain"
|
|
}
|
|
```
|
|
|
|
## Certificate information
|
|
|
|
Specify certificate information either with a directory or
|
|
directly with the content of the files for connecting to the Docker host via TLS.
|
|
|
|
```terraform
|
|
provider "docker" {
|
|
host = "tcp://your-host-ip:2376/"
|
|
|
|
# -> specify either
|
|
cert_path = pathexpand("~/.docker")
|
|
|
|
# -> or the following
|
|
ca_material = file(pathexpand("~/.docker/ca.pem")) # this can be omitted
|
|
cert_material = file(pathexpand("~/.docker/cert.pem"))
|
|
key_material = file(pathexpand("~/.docker/key.pem"))
|
|
}
|
|
```
|
|
|
|
<!-- schema generated by tfplugindocs -->
|
|
## Schema
|
|
|
|
### Optional
|
|
|
|
- **ca_material** (String) PEM-encoded content of Docker host CA certificate
|
|
- **cert_material** (String) PEM-encoded content of Docker client certificate
|
|
- **cert_path** (String) Path to directory with Docker TLS config
|
|
- **host** (String) The Docker daemon address
|
|
- **key_material** (String) PEM-encoded content of Docker client private key
|
|
- **registry_auth** (Block List, Max: 1) (see [below for nested schema](#nestedblock--registry_auth))
|
|
|
|
<a id="nestedblock--registry_auth"></a>
|
|
### Nested Schema for `registry_auth`
|
|
|
|
Required:
|
|
|
|
- **address** (String) Address of the registry
|
|
|
|
Optional:
|
|
|
|
- **config_file** (String) Path to docker json file for registry auth
|
|
- **config_file_content** (String) Plain content of the docker json file for registry auth
|
|
- **password** (String, Sensitive) Password for the registry
|
|
- **username** (String) Username for the registry |