Skip to content

Instantly share code, notes, and snippets.

@mcouthon
Created July 24, 2019 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcouthon/dd2626afaf12d30b280f4dbfe9686e7e to your computer and use it in GitHub Desktop.
Save mcouthon/dd2626afaf12d30b280f4dbfe9686e7e to your computer and use it in GitHub Desktop.
Simple Dockerfile to work with Terraform

To run TF code, put the Dockerfile into the same folder that has your TF file(s) in it, and run (from inside the folder):

docker build --pull -t tf_docker .

docker run -i --rm tf_docker
# Use the light version of the image that contains just the latest binary
FROM hashicorp/terraform:light
# The app folder will contain all our files
WORKDIR /app
# Put all your configration files in the same folder as the Dockerfile
COPY . /app
# Initalize terraform with local settings and data
RUN ["terraform", "init"]
# Plan and execute the configurations
CMD [ "apply"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment