Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Deploying Nginx Web Server with Docker

Tech 2

Start by pulling the official Nginx image from Docker Hub. The default tag retrieves the latest stable release optimized for general use:

docker pull nginx

For environments prioritizing minimal resource usage, use the Alpine Linux-based variant instead:

docker pull nginx:alpine

Confirm the image exists in your local registry:

docker image ls | grep nginx

Expected output includes repository details, image digests, and size differences between standard and Alpine builds.

Launch a detached container mapping host port 8080 to the standard HTTP port:

docker run -d \
  --name http-gateway \
  -p 8080:80 \
  --restart unless-stopped \
  nginx

The --restart policy ensures the service resumes after system reboots. For persistent custom configurations, mount configuration and content direcotries from the host filesystem:

docker run -d \
  --name configured-proxy \
  -v $(pwd)/nginx.conf:/etc/nginx/nginx.conf:ro \
  -v $(pwd)/html:/usr/share/nginx/html:ro \
  -p 8080:80 \
  nginx

Verify active containers filtering by the Nginx ancestor image:

docker ps --filter "ancestor=nginx" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"

Access the deployment via http://localhost:8080 to view the default welcome page, confirming the web server operates correctly inside the containeirzed environment.

To discover available image variants including specific version tags:

docker search nginx --filter is-official=true --limit 5

This query returns official repositories suitable for production deployments, excluding community modifications.

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.