Quick docker / nginx

Overview

A memo when you want to do nginx / Hello World with docker quickly

Use

Hello World on CloudRun and Fargate. .. ..

Preparation

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>

command

#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

Remarks

I forget it every time. .. ..

sample https://github.com/koffe0522/docker-nginx

Recommended Posts

Quick docker / nginx
How to set Docker nginx
docker
docker memo
kubernetes + docker
spring × docker
[Docker] Use environment variables in Nginx conf
Docker basics
Environment construction with Docker (Ubuntu20.04) + Laravel + nginx
Docker installation
Quick build maven project using maven docker container
[docker] [nginx] Make a simple ALB with nginx
Docker command
Docker memorandum
Understand Docker
Docker memorandum
Simple installation of nginx and Docker using ansible
React + Django + Nginx + MySQL environment construction with Docker