0
0
Nginxdevops~30 mins

Official Nginx Docker image - Mini Project: Build & Apply

Choose your learning style9 modes available
Using the Official Nginx Docker Image
📖 Scenario: You want to quickly set up a simple web server to serve a static website using Docker. Nginx is a popular web server, and the official Nginx Docker image makes it easy to run Nginx inside a container.This project will guide you step-by-step to create a Docker container running Nginx, serve a simple HTML page, and verify it works.
🎯 Goal: Build a Docker container using the official Nginx image that serves a custom HTML page on your local machine.
📋 What You'll Learn
Create a basic HTML file named index.html with specific content
Write a Dockerfile that uses the official nginx:latest image
Copy the index.html file into the correct Nginx directory inside the container
Build and run the Docker container exposing port 8080
Verify the web page is served correctly by printing the curl command output
💡 Why This Matters
🌍 Real World
Developers and system administrators often use the official Nginx Docker image to quickly deploy web servers for testing or production.
💼 Career
Knowing how to use official Docker images like Nginx is a key skill for DevOps roles, enabling fast and consistent deployment of web services.
Progress0 / 4 steps
1
Create the HTML file
Create a file named index.html with the exact content: <h1>Welcome to My Nginx Server</h1>
Nginx
Need a hint?

Use a text editor to create index.html with the heading inside.

2
Write the Dockerfile
Create a file named Dockerfile with these exact lines:
FROM nginx:latest
COPY index.html /usr/share/nginx/html/index.html
Nginx
Need a hint?

The Dockerfile must start with FROM nginx:latest and copy index.html to the Nginx html folder.

3
Build and run the Docker container
Run these exact commands in your terminal:
docker build -t my-nginx .
docker run -d -p 8080:80 --name webserver my-nginx
Nginx
Need a hint?

Use docker build to create the image and docker run to start the container on port 8080.

4
Verify the Nginx server is running
Run the command curl http://localhost:8080 and print its output exactly.
Nginx
Need a hint?

Use curl http://localhost:8080 in your terminal to see the page content.