Nginxしたい(nginx

# https://hub.docker.com/_/nginx
# Tags:
# - nginx:latest
# - nginx:stable-bookworm-perl
# - nginx:1.27
# - nginx:1.27-perl
# - nginx:1.27-bookworm
# - nginx:1.27-bookworm-perl
# - nginx:1.27-alpine
# - nginx:1.27-alpine-pel
# - nginx:1.27-alpine-otel
# - nginx:apline-slim
#
# $ docker compose up --detach
# $ open http://localhost:8082
# $ docker compose down --volumes

services:
  nginx:
    image: nginx:1.27
    ports:
      - 8082:80
    #volumes:
    #  - ./html:/usr/share/nginx/html:ro
    #  - ./conf:/etc/nginx:ro

コンテナーを起動したい

$ docker compose up -d

コンテナーで操作したい

$ docker compose exec nginx bash

コンテナーを終了したい

$ docker compose down

Nginxについて

Nginxは高速で軽量なウェブサーバーのDockerイメージです。起動後、ブラウザで http://localhost:8080 を開いて「Welcome to nginx!」と表示されればOKです。ローカルの ./html ディレクトリがNginxのドキュメントルート(/usr/share/nginx/html)にマウントされているため、このディレクトリにHTMLファイルを配置すればウェブサーバーで公開できます。コンテナー内で apt-get install を使ってツールを追加することもできます。