Nginx guide

Deploy Nginx 1.22.1 in Docker with /data/nginx as the host mount

A practical guide to using install_nginx_base_docker.sh when Docker is already ready and you want a predictable Nginx 1.22.1 container with host-mounted config, content, and logs.

5 min read · 2026-03-23

What this script sets up

install_nginx_base_docker.sh is for hosts that already have Docker and need a clean, repeatable Nginx 1.22.1 entrypoint without building a Compose file first.

It prepares /data/nginx as the single host-side working directory, so config, static content, and logs all stay visible and editable outside the container.

Terminal output showing install_nginx_base_docker.sh deploying nginx:1.22.1
A real run after sanitizing the host name: the script prepares /data/nginx, pulls nginx:1.22.1, and starts the nginx-1221 container.

What it writes to /data/nginx

The script creates html, conf.d, and logs directories, plus a baseline nginx.conf and a default virtual host. It also writes a placeholder index page so the service is visibly alive right after startup.

  • /data/nginx/nginx.conf
  • /data/nginx/conf.d/default.conf
  • /data/nginx/html/index.html
  • /data/nginx/logs/

Where this pattern fits best

This pattern is a strong fit for helper.sh-style hosts that need a small, reviewable web entrypoint: static pages, reverse-proxy front doors, download endpoints, or quick maintenance pages.

Because the container is disposable and the important files live on the host, you can rebuild or upgrade the container later without losing your site content or hand-edited config.

A successful installation run

The successful run shows the local image build completing, the existing container being recreated safely, and the Workerman health check passing.

Inside the container, Workerman runs in the foreground, while Docker is responsible for process supervision and restart behavior.

Terminal output showing install_workerman3524_base_docker.sh deploying Workerman 3.5.24 successfully
A successful deployment after enabling archived Debian sources and the pcntl extension. The container runs Workerman in the foreground, while Docker handles supervision and restart.

Recommended checks after deployment

After the script finishes, confirm that the container is running, the host ports are mapped as expected, and the placeholder page or /healthz endpoint is reachable from the server itself.

Browser view of the default Nginx page created by install_nginx_base_docker.sh
If this placeholder page opens normally, the container, port mapping, and mounted site content are all working together.
  • docker ps
  • docker logs -f nginx-1221
  • curl http://127.0.0.1/healthz
  • docker exec -it nginx-1221 nginx -t

関連トピック

Ubuntu 24.04 deployment basics

Install Docker, bootstrap common runtime services, and keep fresh Ubuntu 24.04 hosts ready for application rollout.

トピックを見る

Docker base services for application hosts

Use helper.sh scripts to standardize containerized Nginx, MySQL, Redis, PHP, and Workerman services on long-lived hosts.

トピックを見る

問題ページ

How to install Nginx with Docker

Bring up a baseline Nginx container with fixed host paths so config, logs, and web content stay predictable.

ページを見る