DEV Community

Cover image for Provision An NGINX Server Using Docker On Windows
Abisola Adesegun
Abisola Adesegun

Posted on

Provision An NGINX Server Using Docker On Windows

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.

Image description

Step 2: Create a file
Create another file called main.tf and paste the following Terraform configuration into it.

Image description

Image description

Step 3: Provisioning Nginx using Terraform

  • Initialize

To allow terraform interact with Docker, start the project with the folloeing code:

Image description

Image description

  • Plan

To Check or review changes.

Copy code

Image description

Image description

  • Apply

Provision the NGINX server container with apply. When Terraform asks you to confirm type yes and press ENTER.

Image description

Image description

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.

Image description

Image description

Image description

Step 5: Stop Container
To stop the container,

Copy code and run

Image description

Image description

Image description

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)