Git Product home page Git Product logo

terraform-provider-docker's Introduction

Docker logo Terraform logo Kreuzwerker logo

Terraform Provider for Docker

Release Installs Registry License
Go Status Lint Status Go Report Card

Requirements

  • Terraform >=0.12.x
  • Go 1.18.x (to build the provider plugin)

Building The Provider

$ git clone [email protected]:kreuzwerker/terraform-provider-docker
$ make build

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 = "2.23.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
    }
  }
}

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

terraform-provider-docker's People

Contributors

mavogel avatar renovate[bot] avatar suzuki-shunsuke avatar xanderflood avatar junkern avatar grubernaut avatar radeksimko avatar jen20 avatar colinhebert avatar ryane avatar bhuisgen avatar mitchellh avatar dubo-dubon-duponey avatar phinze avatar dmportella avatar appilon avatar stack72 avatar edgarpoce avatar lvjp avatar mkuzmin avatar jefferai avatar innovate-invent avatar renovate-bot avatar captn3m0 avatar paulbellamy avatar mavidser avatar katbyte avatar kyhavlov avatar hmcgonig avatar baboune avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.