Terraform Provider - Docker
Find a file
Jonatan Reiners 09528d1c0e
chore: update Go version to 1.22 for consistency across workflows, jo… (#613)
* chore: update Go version to 1.22 for consistency across workflows, jobs, and modules.

* build: Update GitHub Actions setup-go and golangci-lint versions.

* refactor: Replace ioutil.ReadFile and ioutil.ReadAll with os.ReadFile and io.ReadAll.

* go fmt

* 🔄 Update actions/checkout and actions/setup-go to v4 and v5, respectively.

*  Refactor: Add b64 function to convert file to base64 in testacc_setup.sh.

*  Update Go version requirement in CONTRIBUTING.md.

*  Fix typo and improve error message format.

*  enhance: Improve error message in TestAccDockerContainer_uploadAsBase64.

*  Fix: Update file permissions for test2.txt in docker container tests.
2024-05-08 14:59:49 +02:00
.chglog chore: Automate changelog generation [skip ci] 2022-07-14 15:36:05 +02:00
.github chore: update Go version to 1.22 for consistency across workflows, jo… (#613) 2024-05-08 14:59:49 +02:00
assets docs: update readme with logos and subsections (#235) 2021-06-23 17:33:00 +02:00
docs chore: Prepare release v3.0.2 2023-03-17 16:53:28 +01:00
examples chore: Prepare release v3.0.2 2023-03-17 16:53:28 +01:00
internal/provider chore: update Go version to 1.22 for consistency across workflows, jo… (#613) 2024-05-08 14:59:49 +02:00
scripts chore: update Go version to 1.22 for consistency across workflows, jo… (#613) 2024-05-08 14:59:49 +02:00
templates docs: correct spelling of "networks_advanced" (#517) 2023-02-20 09:27:23 +01:00
testdata feat: Prepare v3 release (#503) 2023-01-13 13:11:51 +01:00
tools fix: Switch to proper go tools mechanism to fix website-* workflows. (#399) 2022-07-11 14:55:15 +02:00
.gitignore chore/refactor tests (#201) 2021-05-31 16:11:49 +09:00
.go-version chore: update Go version to 1.22 for consistency across workflows, jo… (#613) 2024-05-08 14:59:49 +02:00
.golangci.yml feat: migrate to terraform-sdk v2 (#102) 2021-03-18 08:30:54 +01:00
.goreleaser.yml fix(deps): update module github.com/golangci/golangci-lint to v1.39.0 (#166) 2021-04-09 11:56:56 +02:00
.markdownlinkcheck.json feat/doc generation (#193) 2021-05-21 21:30:56 +09:00
.markdownlint.yml feat/doc generation (#193) 2021-05-21 21:30:56 +09:00
CHANGELOG.md chore: Prepare release v3.0.2 2023-03-17 16:53:28 +01:00
CODE_OF_CONDUCT.md docs: adds coc and contributing 2020-12-24 16:27:35 +01:00
CONTRIBUTING.md chore: update Go version to 1.22 for consistency across workflows, jo… (#613) 2024-05-08 14:59:49 +02:00
GNUmakefile fix: Set OS_ARCH from GOHOSTOS and GOHOSTARCH (#477) 2022-11-07 15:12:30 +01:00
go.mod chore: update Go version to 1.22 for consistency across workflows, jo… (#613) 2024-05-08 14:59:49 +02:00
go.sum chore: update Go version to 1.22 for consistency across workflows, jo… (#613) 2024-05-08 14:59:49 +02:00
LICENSE initial commit 2017-06-05 20:59:08 +00:00
main.go fix: Correct provider name to match the public registry (#462) 2022-09-30 17:25:11 +02:00
README.md chore: Prepare release v3.0.2 2023-03-17 16:53:28 +01:00
renovate.json5 chore: Exclude examples directory from renovate. 2022-06-22 21:33:56 +02:00

Docker logo Terraform logo Kreuzwerker logo

Terraform Provider for Docker

Release Installs Registry License
Go Status Lint Status Go Report Card

Documentation

The documentation for the provider is available on the Terraform Registry.

Do you want to migrate from v2.x to v3.x? Please read the 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"
      version = "3.0.2"
    }
  }
}

# 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.

Stargazers over time

Stargazers over time