Infrastructure as Code (IaC) with Terraform
π Objective
Provision a local Docker container using Terraform.
π§° Tools Used
- Terraform
- Docker
π Project Structure
terraform-docker-app/
βββ main.tf
βββ apply-log.txt
βββ README.md
π Steps Performed
1. β Wrote Terraform Configuration
File: main.tf
- Pulled the officialΒ nginxΒ Docker image.
- Created a container namedΒ
nginx-container. - Exposed container portΒ
80Β to host portΒ8081Β (sinceΒ8080Β is used by Jenkins).
2. β Terraform Commands Used
terraform init # Initialize the project
terraform plan # See execution plan
terraform apply # Apply infrastructure changes
tee # log the output
terraform destroy # Tear down the infrastructure
π Access the Container
After applying the configuration, open your browser:
http://localhost:8081 Youβll see the nginx default welcome page.
π§ͺ Verification
To confirm the container is running:
docker ps
ποΈ Clean Up
To remove the container:
terraform destroy -auto-approve

