Executing Terraform in a Docker container
In the previous recipes of this chapter, we discussed how to install Terraform locally, either manually or via a script, for Windows and Linux.
In this recipe, we will learn how to run Terraform in a Docker container, which will allow us to enjoy the following benefits:
- There is no need to install Terraform locally
- We can have a Terraform runtime environment that’s independent of the local operating system
- We can test our Terraform configuration with different versions of Terraform
Let’s get started!
Getting ready
To complete this recipe, you’ll need to know about Docker and its commands, as well as how to write Dockerfiles. To learn basic expressions of Dockerfiles, please read the documentation: https://docs.docker.com/get-started/overview/.
On our local computer, we installed Docker using a tool called Docker Desktop for Windows.
For Docker installation guides...