Docker Provider

The Docker provider is used to interact with Docker containers and images. It uses the Docker API to manage the lifecycle of Docker containers. Because the Docker provider uses the Docker API, it is immediately compatible not only with single server Docker but Swarm and any additional Docker-compatible API hosts.

Use the navigation to the left to read about the available resources.

Note: The Docker provider is new as of Terraform 0.4. It is ready to be used but many features are still being added. If there is a Docker feature missing, please report it in the GitHub repo.

Example Usage

# Configure the Docker provider
provider "docker" {
    host = "tcp://"

# Create a container
resource "docker_container" "foo" {
    image = "${docker_image.ubuntu.latest}"
    name = "foo"

resource "docker_image" "ubuntu" {
    name = "ubuntu:latest"

Registry Credentials

The initial (current) version of the Docker provider doesn’t support registry authentication. This limits any use cases to public images for now.

Argument Reference

The following arguments are supported:

~> NOTE on Certificates and docker-machine: As per Docker Remote API documentation, in any docker-machine environment, the Docker daemon uses an encrypted TCP socket (TLS) and requires cert_path for a successful connection. As an alternative, if using docker-machine, run eval $(docker-machine env <machine-name>) prior to running Terraform, and the host and certificate path will be extracted from the environment.

See the source of this document at Terraform.io