Dockerizing Nginx Applications

1 min read

Authors
banner
Table of Contents

Dockerizing Nginx Applications

Basic Dockerfile

dockerfile
FROM nginx:latest
COPY nginx.conf /etc/nginx/nginx.conf
COPY html /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

Build Image

bash
docker build -t my-nginx:1.0 .

Run Container

bash
docker run -p 80:80 my-nginx:1.0

Docker Compose

yaml
version: '3'
services:
  nginx:
    image: nginx:latest
    ports:
      - "80:80"
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
      - ./html:/usr/share/nginx/html

Containerized!

© 2026 Vijay Rajendranbuilt with Next.js & Tailwind · deployed on Vercel