Public | Automated Build

Last pushed: 7 days ago
Short Description
Automatic builds of Terraform. See README for more use and info.
Full Description

terraform Docker Container

Usage

This repository automatically builds containers for using the terraform command line program. It contains two distinct varieties of build, a light version, which just contains the binary, and a full version while compiles the binary from source inside the container before exposing it for use. Which you want will depend on use.

light (default)

The light version of this container will copy the current stable version of the binary into the container, and set it for use as the default entrypoint. This will be the best option for most uses, and if you are just looking to run the binary from a container. The latest tag also points to this version.

You can use this version with the following:

docker run -i -t hashicorp/terraform:light <command>

For example:

docker run -i -t hashicorp/terraform:light plan main.tf
full

The full version of this container contains all of the source code found in the parent repository. Using Google's official golang image as a base, this container will copy the source from the master branch, build the binary, and expose it for running. Since the build is done on Docker Hub, the container is ready for use. Because all build artifacts are included, it should be quite a bit larger than the light image. This version of the container is useful for development or debugging.

You can use this version with the following:

docker run -i -t hashicorp/terraform:full <command>

For example:

docker run -i -t hashicorp/terraform:full plan main.tf
Docker Pull Command
Owner
hashicorp
Source Repository

Comments (12)
sjourdan
2 months ago

this container will copy the source from the master branch

It builds the version specified in the Dockerfile, which is the latest tagged release, and therefore do not build master.

nickm4062
7 months ago

git and ssh are missing from the image so module references that use git::ssh do not work.

git is in the full image but ssh is not

sstarcher
8 months ago

To mount a local file do the following.
terraform run -v $PWD:/data --workdir=/data hashicorp:terraform <command>

sstarcher
8 months ago

@timfallmk if you mount -v $PWD:/ it will overwrite all data in the docker container including the binaries. That is certainly not an option.

berinle
10 months ago

@alars, thanks! Hit the same issue. Changing from amd64 to 386 fixed it

alars
a year ago

Hmm, the images using the base image alpine seems to be broken. Update the terraform arch from amd64 to 386 and it should do the trick.

timfallmk
a year ago

@gamename

You can create a new dockerfile from either hashicorp/terraform or hashicorp/packer and add the other one in if you like.

gamename
a year ago

What if I need a container with terraform and packer in it?

timfallmk
a year ago

@torumakabe Yeah, we're still figuring out how to manage versions and tags here properly. It will be automated at some point, but I'll try and keep on top of it for now.

torumakabe
a year ago

Coud you check a consisitency between tag and terraform version? It seems that is inconsistent now.

For example, an image tagged 0.6.14 contains terraform 0.6.15 binary.

https://hub.docker.com/r/hashicorp/terraform/builds/beffrc4dpahzhftmqqrfr2n/