2015-03-29 04:05:17 +02:00
---
layout: "docker"
page_title: "Provider: Docker"
sidebar_current: "docs-docker-index"
description: |-
The Docker provider is used to interact with Docker containers and images.
---
# 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
2015-04-02 17:43:40 +02:00
the Docker provider uses the Docker API, it is immediately compatible not
2015-03-29 04:05:17 +02:00
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.
2015-03-31 23:48:57 +02:00
< div class = "alert alert-block alert-info" >
< strong > Note:< / strong > 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.
< / div >
2015-03-29 04:05:17 +02:00
## Example Usage
```
# Configure the Docker provider
provider "docker" {
2016-09-17 17:57:37 +02:00
host = "tcp://127.0.0.1:2376/"
2015-03-29 04:05:17 +02:00
}
# Create a container
resource "docker_container" "foo" {
image = "${docker_image.ubuntu.latest}"
name = "foo"
}
resource "docker_image" "ubuntu" {
name = "ubuntu:latest"
}
```
2016-07-26 18:07:35 +02:00
## 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.
2015-03-29 04:05:17 +02:00
## Argument Reference
The following arguments are supported:
* `host` - (Required) This is the address to the Docker host. If this is
blank, the `DOCKER_HOST` environment variable will also be read.
* `cert_path` - (Optional) Path to a directory with certificate information
for connecting to the Docker host via TLS. If this is blank, the
`DOCKER_CERT_PATH` will also be checked.
2016-09-20 20:52:40 +02:00
Note: As per [Docker Remote API documentation ](https://docs.docker.com/engine/reference/api/docker_remote_api/ ), in any docker-machine environment, the Docker daemon uses an encrypted TCP socket (TLS) and requires `cert_path` for a successful connection.