• Stars
    star
    608
  • Rank 73,735 (Top 2 %)
  • Language
    Go
  • License
    Mozilla Public Li...
  • Created about 4 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Terraform Docker provider
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 [email protected]: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

More Repositories

1

m1-terraform-provider-helper

CLI to support with downloading and compiling terraform providers for Mac with M1 chip
Go
486
star
2

envplate

Docker-friendly trivial templating for configuration files using environment keys
Go
328
star
3

awsu

Enhanced account switching for AWS, supports Yubikey as MFA source
Go
175
star
4

envsec

Encrypted environment variables via AWS KMS
Go
29
star
5

Call-AWS-API-With-Bash

Shell
14
star
6

kreuzlaker

Python
11
star
7

kafka-consumer-testing

demo application for testing a Kafka consumer with Avro message schema with Testcontainers using Kafka with embedded Zookeeper and no Schema Registry container
Java
9
star
8

DKT.huginn_readability_agent

Ruby
8
star
9

aws-game-day-2022-squirrel-force

Squirrel Force to the Win
6
star
10

awssd

Utility that creates Route53 A records for EC2 instances following a tag convention
Go
6
star
11

tacks

Executable CloudFormation stacks
Go
6
star
12

yess

yess enables splitting secrets into shares using a Yubikey-based threshold schema
Go
5
star
13

homebrew-taps

Brew support for various kreuzwerker tools
Ruby
5
star
14

ecr-proxy

nginx configuration for proxying requests against an AWS EC2 Container Registry
Nginx
5
star
15

blog-bidirectional-contract-testing-consumer

Java
5
star
16

blog-bidirectional-contract-testing-provider

Java
4
star
17

parallel-docker-uats

Ruby
3
star
18

DKT.huginn_dkt_curation_agents

Ruby
3
star
19

gva

Varnish CLI interface in golang
Go
3
star
20

blog-testing-with-cdk

Examples from blog post https://kreuzwerker.de/post/infrastructure-tests-with-cdk
TypeScript
2
star
21

DKT.huginn_website_metadata_agent

HTML
2
star
22

aodb

Atlassian OnDemand backup
Ruby
2
star
23

awsips

Client utility to query IP addresses used by Amazon Web Services
Go
2
star
24

awhois

Determine if IP addresses belong to AWS
Go
1
star
25

cdk-nag-example

How to
TypeScript
1
star
26

arebot

Go
1
star
27

vmimport-terraform

Terraform provisioning for AWS VM import
HCL
1
star
28

terraform-aws-es

Terraform configurations to launch an Amazon Elasticsearch cluster in a VPC
HCL
1
star
29

safed

😍🔒 - readme driven development workshop
1
star
30

did-you-hear-publisher

Slack bot backend for daily news publication
TypeScript
1
star