A memo when you want to do nginx / Hello World with docker quickly
Hello World on CloudRun and Fargate. .. ..
Directory structure
.
├── 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>
#Build
$ docker build --tag hello-nginx .
#Confirmation
$ docker images -a hello-nginx
#Start-up
$ docker run -d --name hello-nginx-container -p 80:80 hello-nginx
#Stop
$ docker stop hello-nginx-container
#Delete
$ docker rm hello-nginx-container
I forget it every time. .. ..
sample https://github.com/koffe0522/docker-nginx
Recommended Posts