Dockerizing Nginx Applications

1 min read

Authors
banner

Dockerizing Nginx Applications

Basic 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

docker build -t my-nginx:1.0 .

Run Container

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

Docker Compose

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

Containerized!

© 2025 Vijay Rajendran