Provision a local Docker container running Nginx using Terraform.
- Terraform
- Docker
main.tf
(Terraform configuration file)- Execution logs
- Install Docker
- Install Terraform
-
Clone or copy this repository/project directory.
-
Update the host path in
main.tf
if needed:- The current config mounts the host directory
$HOME/T4/nginx/
to the container's/usr/share/nginx/
. - Make sure
$HOME/T4/nginx/
exists on your machine.
- The current config mounts the host directory
-
Initialize Terraform:
terraform init
-
Preview the execution plan:
terraform plan
-
Apply the configuration to create the container:
terraform apply
- Type
yes
to confirm.
- Type
-
Check container status:
docker ps
-
View Terraform-managed resources:
terraform state list
-
Destroy all resources when finished:
terraform destroy
- Make sure Docker is running before applying the configuration.
- Review the
m 5051 ain.tf
file and edit as needed for your environment. - All state files and sensitive info should be added to
.gitignore
.
.terraform/
terraform.tfstate.*