Install Nginx with docker

By | 2020년 8월 20일
Table of Content

Install Nginx with docker

nginx 가 root 권한으로 실행됩니다.

Nginx 설치하기

mkdir nginx
cd nginx

vi docker-compose.yml
version: '3'

networks:
  test:

services:
  nginx:
    image: nginx
    container_name: nginx
    ports:
      - "80:80"
    networks:
      - test
    restart: always
docker-compose up -d
docker container logs nginx

Nginx 커스터마이징 하기

sudo mkdir -p /data/docker/nginx/www
sudo mkdir -p /data/docker/nginx/log

sudo vi /data/docker/nginx/www/index.html
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
</head>
<body>
<h1>Welcome to nginx!</h1>
</body>
</html>
vi docker-compose.yml
version: '3'

networks:
  test:

services:
  nginx:
    image: nginx
    container_name: nginx
    ports:
      - "80:80"
    volumes:
      - /data/docker/nginx/www:/usr/share/nginx/html
      - /data/docker/nginx/log:/var/log/nginx
    networks:
      - test
    restart: always
docker-compose down
docker-compose up -d

답글 남기기