LoginSignup
0
1

More than 1 year has passed since last update.

Docker CentOS8にnginx入れてみた

Last updated at Posted at 2021-06-02

概要

Dockerを使ってCentOS8上にnginxを入れるだけのシンプルな環境構築の方法をご紹介します。

環境

  • maxOS BigSur 11.2.3
  • Docker version 20.10.6
  • docker-compose version 1.29.1

構成

.
├── docker
│   └── app
│       └── Dockerfile
└── docker-compose.yml

手順

1. docker-compose.yml作成

シンプルにappコンテナのみを作成します。

docker-compose.yml
version: "3.9"
services:
  app:
    build:
      context: ./docker/app
    ports:
      - "80:80"

2. Dockerfile作成

CentOS8では、yumコマンドが廃止されdnfコマンドが採用されたんですねー。

Dockerfile
FROM centos:centos8

RUN dnf -y update

# install nginx
RUN dnf install -y nginx
CMD ["nginx", "-g", "daemon off;"]

WORKDIR /usr/share/nginx/html

ちなみに、デフォルトのドキュメントルートは/usr/share/nginx/htmlになりますー。

3. 確認

3-1. 起動

docker-compose up -d

3-2. 確認

http://localhost にアクセスしてみましょう。
nginxのテストページが表示されていたらOKです。

スクリーンショット 2021-06-02 12.15.38.png

3-3. 停止

docker-compose down

参考

0
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
0
1