Table of Content
Step 1: Create a directory
Step 2: Create a file
Step 3: Provisioning Nginx using Terraform
Step 4: Verification
Step 5: Stop Container
To provision an NGINX server using Docker on Windows, you can follow this step-by-step guide:
Prerequisites:
Install Docker Desktop:
Download and install Docker Desktop for Windows from here.
Ensure Docker Desktop is running, and WSL2 integration is enabled (recommended but optional).
Step 1: Create a directory
Create a directory named learn-terraform-docker-container. This working directory houses the configuration files that you write to describe the infrastructure you want Terraform to create and manage.
Step 2: Create a file
Create another file called main.tf and paste the following Terraform configuration into it.
Step 3: Provisioning Nginx using Terraform
- Initialize
To allow terraform interact with Docker, start the project with the folloeing code:
- Plan
To Check or review changes.
Copy code
- Apply
Provision the NGINX server container with apply. When Terraform asks you to confirm type yes and press ENTER.
Step 4: Verification
Verify the existence of the NGINX container by visiting localhost:8000 in your web browser or running docker ps to see the container.
Step 5: Stop Container
To stop the container,
Copy code and run
By following these steps, you have successfully provisioned an NGINX server on Windows using Docker. This setup can be customized by mounting configurations and static files into the container as needed.
Top comments (0)