Creating a Docker container using Terraform
To start this chapter dedicated to Docker and Kubernetes, we will learn how to automate Docker operations using Terraform.
Let’s get started!
Getting ready
To complete this recipe, you will need to install Docker Engine by reading the documentation here: https://docs.docker.com/engine/. In this recipe, we assume that Docker is already installed and running on the same workstation on which we run Terraform.
In this recipe, we will discuss how to pull a Docker image named mikaelkrief/demobook
from Docker Hub, and then run a container from this pulled image.
We will not learn how to build this Docker image from the dockerfile, but the source code for this Dockerfile is available here: https://github.com/PacktPublishing/Learning-DevOps-Second-Edition/blob/main/CHAP09/appdocker/Dockerfile.
Now, in this recipe, we will learn how to pull this image and how to run it as a container using Terraform configuration.
...