No description
  • Go 99.3%
  • Makefile 0.7%
Find a file
2026-03-24 20:41:19 -04:00
.github add copyright headers (#65) 2024-10-21 10:05:26 -04:00
docs docs: clarify OAT authentication support (#130) 2026-03-24 20:41:19 -04:00
examples Add docker_hub_repository_tags data source for digest-pinned image rfs (#102) 2025-07-09 11:19:29 -04:00
internal docs: clarify OAT authentication support (#130) 2026-03-24 20:41:19 -04:00
template add copyright headers (#65) 2024-10-21 10:05:26 -04:00
tools auth: rewrite terraform provider auth (#103) 2025-07-29 10:04:43 -04:00
.gitignore auth: rewrite terraform provider auth (#103) 2025-07-29 10:04:43 -04:00
.goreleaser.yml github: add release workflow 2024-08-22 17:24:37 -04:00
CHANGELOG.md Migrate everything from private repo to Docker org repo 2024-08-07 11:45:14 -04:00
CONTRIBUTING.md contributing: add release steps (#91) 2025-04-14 12:43:11 -04:00
go.mod build(deps): bump google.golang.org/grpc (#129) 2026-03-18 21:17:13 -04:00
go.sum build(deps): bump google.golang.org/grpc (#129) 2026-03-18 21:17:13 -04:00
LICENSE Create LICENSE 2024-08-21 10:03:44 -04:00
main.go add copyright headers (#65) 2024-10-21 10:05:26 -04:00
Makefile lint: update ltag repo (#89) 2025-04-09 18:30:49 -04:00
README.md docs: clarify OAT authentication support (#130) 2026-03-24 20:41:19 -04:00
SECURITY.md Add ISSUE_TEMPLATES and other placeholders 2024-08-14 10:32:11 -04:00
terraform-registry-manifest.json Migrate everything from private repo to Docker org repo 2024-08-07 11:45:14 -04:00

Docker Terraform Provider

Manage Docker-hosted resources (such as repositories, teams, organization settings, and more) using Terraform.

Warning

This project is not for managing objects in a local docker engine. If you would like to use Terraform to interact with a docker engine, kreuzwerker/docker is a fine provider.

Documentation: https://registry.terraform.io/providers/docker/docker/latest/docs

Requirements

  • Terraform >= 1.1
  • Go >= 1.21 (to build the provider plugin)

Usage

Below is a basic example of how to use the Docker services Terraform provider to create a Docker repository.

terraform {
  required_providers {
    docker = {
      source  = "docker/docker"
      version = "~> 0.2"
    }
  }
}

provider "docker" { }

resource "docker_hub_repository" "example" {
  name        = "example-repo"
  namespace   = "example-namespace"
  description = "This is an example Docker repository"
  private     = true
}

Authentication

We have multiple ways to set your Docker credentials.

Setting credentials

Use docker login to log in to a registry. The docker CLI will store your credentials securely in your credential store, such as the operating system native keychain. The Docker Terraform provider will use these credentials automatically.

cat ~/my_password.txt | docker login --username my-username --password-stdin

If you'd like to use a different account for running the provider, you can set credentials in the environment. When using an organization access token (OAT), set DOCKER_USERNAME to the organization name:

export DOCKER_USERNAME=my-username
export DOCKER_PASSWORD=my-secret-token
terraform plan ...

Credential types

You can create a personal access token (PAT) to use as an alternative to your password for Docker CLI authentication.

A "Read, Write, & Delete" PAT can be used to create, edit, and manage permissions for Docker Hub repositories.

The advantage of PATs is that they have many security benefits over passwords.

Unfortunately, PATs are limited to managing repositories. If you'd like to use this provider to manage organizations and teams, you will need to authenticate with a password.

Organization access tokens (OATs) are a separate credential type for organization-scoped automation. Authenticate with the organization name as the username and the OAT as the password.

OATs can be used with this provider for organization APIs when the token has the required permissions for the target API, such as Member Read, Member Edit, Invite Read, Invite Edit, Group Read, and Group Edit.

When the provider auto-resolves credentials from Docker's config file, it currently prefers Docker Desktop's cached access token before docker login pull credentials. If you want to force OAT usage, set DOCKER_USERNAME and DOCKER_PASSWORD explicitly or configure them in the provider block.

Organization access tokens are incompatible with Docker Desktop, Image Access Management, and Registry Access Management. Use a password or PAT for those features.

Contributing

We welcome contributions to the Docker services Terraform provider, detailed documentation for contributing & building the provider can be found here

Roadmap

Our roadmap is managed through GitHub issues. You can view upcoming features and enhancements, as well as report bugs or request new features, by visiting our issues page.

License

Copyright 2024 Docker, Inc.

Licensed under the Apache License, Version 2.0.