This project provides a Docker image based on Ubuntu 24.04 with Nginx and related applications pre-installed.
docker build -t nginx-ubuntu .
docker run -p 80:80 -p 443:443 nginx-ubuntu
docker run -p 80:80 -p 443:443 \ -v /path/to/your/nginx.conf:/etc/nginx/nginx.conf \ -v /path/to/your/html:/var/www/html \ nginx-ubuntu
/etc/nginx/nginx.conf/etc/nginx/sites-available//var/www/html/var/log/nginx/To use SSL certificates with Certbot:
docker run -p 80:80 -p 443:443 \ -e DOMAIN=yourdomain.com \ -e EMAIL=admin@yourdomain.com \ nginx-ubuntu
docker exec -it <container_id> certbot --nginx -d yourdomain.com
After running the container, access the test page at:
http://localhost
Replace the default index.html with your content:
docker run -p 80:80 \ -v /path/to/your/html:/var/www/html \ nginx-ubuntu
Create a custom nginx.conf for reverse proxy:
events {} http { upstream backend { server backend-service:3000; } server { listen 80; location / { proxy_pass http://backend; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } } }
# Build with tag
docker build -t nginx-ubuntu:latest .
# Build without cache
docker build --no-cache -t nginx-ubuntu .
# Access container shell
docker exec -it <container_id> /bin/bash
# View nginx logs
docker exec -it <container_id> tail -f /var/log/nginx/access.log
docker exec -it <container_id> tail -f /var/log/nginx/error.log
# Test nginx configuration
docker exec -it <container_id> nginx -t
| Variable | Default | Description |
|---|---|---|
DEBIAN_FRONTEND | noninteractive | Prevents interactive prompts during package installation |
version: '3.8'
services:
nginx:
build: .
ports:
- "80:80"
- "443:443"
volumes:
- ./html:/var/www/html
- ./nginx.conf:/etc/nginx/nginx.conf
restart: unless-stopped
This project is provided as-is for educational and development purposes.