mirror of
https://github.com/kreuzwerker/terraform-provider-docker.git
synced 2026-04-04 08:24:59 -04:00
Terraform Provider - Docker
|
Some checks are pending
Acc Tests / Detect acc-test matrix (push) Waiting to run
Acc Tests / acc-test (push) Blocked by required conditions
Compile Binaries / compile-fast (push) Waiting to run
Compile Binaries / compile (push) Waiting to run
golangci-lint / lint (push) Waiting to run
Unit Tests / unit-test (push) Waiting to run
Website Checks / markdown-link-check (push) Waiting to run
Docs and Website Lint / website-generation (push) Waiting to run
Docs and Website Lint / website-lint-spellcheck-tffmt (push) Waiting to run
Docs and Website Lint / markdown-lint (push) Waiting to run
* Initial plan * fix(container): ignore daemon default log_opts when unset Agent-Logs-Url: https://github.com/kreuzwerker/terraform-provider-docker/sessions/f161d367-0249-44a0-8761-2f1f4d1c54e7 Co-authored-by: Junkern <3775779+Junkern@users.noreply.github.com> * test(container): cover log_opts omitted vs configured state behavior Agent-Logs-Url: https://github.com/kreuzwerker/terraform-provider-docker/sessions/f161d367-0249-44a0-8761-2f1f4d1c54e7 Co-authored-by: Junkern <3775779+Junkern@users.noreply.github.com> * chore: enforce make fmt in copilot instructions Agent-Logs-Url: https://github.com/kreuzwerker/terraform-provider-docker/sessions/2a852f9f-3abb-4c44-b675-66303adfc827 Co-authored-by: Junkern <3775779+Junkern@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Junkern <3775779+Junkern@users.noreply.github.com> Co-authored-by: Martin <Junkern@users.noreply.github.com> |
||
|---|---|---|
| .chglog | ||
| .github | ||
| assets | ||
| docs | ||
| examples | ||
| internal | ||
| scripts | ||
| templates | ||
| testdata | ||
| tools | ||
| .gitignore | ||
| .go-version | ||
| .golangci.yml | ||
| .goreleaser-fast.yml | ||
| .goreleaser.yml | ||
| .markdownlinkcheck.json | ||
| .markdownlint.yml | ||
| .terraform-registry | ||
| CHANGELOG.md | ||
| CODE_OF_CONDUCT.md | ||
| CONTRIBUTING.md | ||
| GNUmakefile | ||
| go.mod | ||
| go.sum | ||
| LICENSE | ||
| main.go | ||
| README.md | ||
| renovate.json5 | ||
Terraform Provider for Docker
Sponsored by Coder
Documentation
The documentation for the provider is available on the Terraform Registry.
You need at least Terraform 1.1.5 to use this provider.
Migration guides:
- Do you want to migrate from
v3.xtov4.x? Please read the V3 - V4 migration guide - Do you want to migrate from
v2.xtov3.x? Please read the V2 - V3 migration guide
Example usage
Take a look at the examples in the documentation of the registry or use the following example:
# Set the required provider and versions
terraform {
required_providers {
# We recommend pinning to the specific version of the Docker Provider you're using
# since new versions are released frequently
docker = {
source = "kreuzwerker/docker"
# or if you want to pull from opentfu
source = "registry.opentofu.org/kreuzwerker/docker"
version = "4.0.0"
}
}
}
# Configure the docker provider
provider "docker" {
}
# Create a docker image resource
# -> docker pull nginx:latest
resource "docker_image" "nginx" {
name = "nginx:latest"
keep_locally = true
}
# Create a docker container resource
# -> same as 'docker run --name nginx -p8080:80 -d nginx:latest'
resource "docker_container" "nginx" {
name = "nginx"
image = docker_image.nginx.image_id
ports {
external = 8080
internal = 80
}
}
# Or create a service resource
# -> same as 'docker service create -d -p 8081:80 --name nginx-service --replicas 2 nginx:latest'
resource "docker_service" "nginx_service" {
name = "nginx-service"
task_spec {
container_spec {
image = docker_image.nginx.repo_digest
}
}
mode {
replicated {
replicas = 2
}
}
endpoint_spec {
ports {
published_port = 8081
target_port = 80
}
}
}
Building The Provider
Go 1.18.x (to build the provider plugin)
$ git clone git@github.com:kreuzwerker/terraform-provider-docker
$ make build
Contributing
The Terraform Docker Provider is the work of many of contributors. We appreciate your help!
To contribute, please read the contribution guidelines: Contributing to Terraform - Docker Provider
License
The Terraform Provider Docker is available to everyone under the terms of the Mozilla Public License Version 2.0. Take a look the LICENSE file.