Install Terraform in Docker Containers
Run Terraform in Docker containers for consistent CI/CD environments. Official HashiCorp image, custom Dockerfiles, and Docker Compose workflows.
Terraform
Install Terraform on Windows Subsystem for Linux (WSL). Ubuntu, Debian, and RHEL on WSL2 with AWS CLI, VS Code integration, and path configuration.
# Inside WSL (Ubuntu)
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install terraform
terraform version# In PowerShell (Admin)
wsl --install
# Restart, then set up Ubuntu username/passwordsudo apt-get update && sudo apt-get install -y gnupg software-properties-common
wget -O- https://apt.releases.hashicorp.com/gpg | \
sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] \
https://apt.releases.hashicorp.com $(lsb_release -cs) main" | \
sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update
sudo apt install terraform
terraform -install-autocompleteTERRAFORM_VERSION="1.8.5"
wget "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip"
unzip "terraform_${TERRAFORM_VERSION}_linux_amd64.zip"
sudo mv terraform /usr/local/bin/
rm "terraform_${TERRAFORM_VERSION}_linux_amd64.zip"curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
aws configure# Install VS Code on Windows, then from WSL:
code .
# Opens VS Code connected to WSL filesystemInstall these VS Code extensions:
# Store Terraform projects in WSL filesystem (faster I/O)
mkdir -p ~/projects/terraform
cd ~/projects/terraform
# DON'T use /mnt/c/ for Terraform projects — very slow file I/O
# Git line endings (prevent CRLF issues)
git config --global core.autocrlf inputWSL2 gives you a native Linux Terraform experience on Windows. Use the official HashiCorp APT repository, store projects in the WSL filesystem (not /mnt/c/), and connect VS Code with the Remote WSL extension. Avoid Windows-native Terraform if you're using WSL — stick to the Linux binary.
Run Terraform in Docker containers for consistent CI/CD environments. Official HashiCorp image, custom Dockerfiles, and Docker Compose workflows.
Install and run Terraform on Ubuntu 26.04 LTS Resolute Raccoon. Covers sudo-rs as default, APT 3.2 rollback, Kernel 7.0, Wayland-only, ROCm, and building...
Install Terraform on Alpine Linux for Docker containers and lightweight environments. Binary install, apk package, and minimal Docker images.
Install Terraform on Arch Linux and Manjaro. Official repository, AUR packages, manual binary install, and tfenv version management.