2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

さくっとdocker/nginx

Last updated at Posted at 2020-11-23

概要

さくっとdockerでnginx/Hello Worldしたいときのメモ

用途

CloudRunやFargateでのHello Worldなど。。。

準備

ディレクトリー構成

.
├── Dockerfile
├── index.html
└── nginx.conf
Dockerfile
FROM nginx:latest

COPY ./index.html /usr/share/nginx/html

EXPOSE 80
nginx.conf
server {
    listen       80;
    server_name  hello_nginx;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}
index.html
<!DOCTYPE html>
<html lang="ja">
<head>
  <meta charset="UTF-8">
  <title>nginx</title>
</head>
<body>
  <h1>Hello World</h1>
</body>
</html>

コマンド

# ビルド
$ docker build --tag hello-nginx .
# 確認
$ docker images -a hello-nginx
# 起動
$ docker run -d --name hello-nginx-container -p 80:80 hello-nginx
# 停止
$ docker stop hello-nginx-container
# 削除
$ docker rm hello-nginx-container

備考

毎回忘れてしまう。。。

サンプル
https://github.com/koffe0522/docker-nginx

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?