Nginx >

dockerでサクッとNginx環境構築

ディレクトリ作成

mkdir -p test_nginx/www
cd test_nginx

Nginxの設定ファイル作成

./default.conf

server {
    listen 80;
    server_name localhost;
    root /var/www;
    index  index.html index.htm;
}

docker-compose.yml の作成

./docker-compose.yml

webserver:
  image: nginx 
  volumes:
   - ./default.conf:/tmp/default.conf
   - ./www:/var/www
  ports:
   - "8080:80"
  command: /bin/sh -c "cat /tmp/default.conf >/etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"

サンプルHTML作成

./www/index.html

<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
</head>
<body>

Test Nginx!

</body>
</html>

起動

docker-compose up

トップ   差分 バックアップ リロード   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2019-01-11 (金) 12:10:16 (1933d)