Skip to content

roiavidan/terraform-dind

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform w/ Docker-in-Docker

This repository provides a minimal Terraform Docker image that can be used by your deployment scripts. It is based on Alpine 3.10.

UPDATE: After reading this article I no longer recommend using this image unless you know what you're doing.

Security considerations

This image is designed to be run in a controlled CI/CD environment and not in your production systems. It DOES NOT change the user! The container will run as root and in order to take advantage of docker-in-docker you must bind-mount the Docker socket onto this container.

This is not a recommended practice and if you choose to use it, you should at least guarantee to have limited network access to your environment and run the Docker daemon with userns-remap.

What's inside?

The image comes with the following utilities:

Usage

In order for you to run other docker from within a Terraform "local-exec" provisioner, this image must be run with a volume mount for binding the Docker daemon socket into the container:

$ docker run --rm -t --init \
    -v "/var/run/docker.sock:/var/run/docker.sock" \
    -v "$(pwd):$(pwd)" -w "$(pwd)" \
    roiavidan/terraform-dind:latest \
    ...