0
0

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起動する

Posted at

nginx起動時にdaemon offを指定することでフォアグラウンドでnginxが起動するようにする。
デーモンで起動するとコンテナが直ぐにストップする。

FROM centos:centos8

RUN dnf install -y nginx

CMD ["nginx", "-g", "daemon off;"]

docker buildでイメージを作成し、docker runでコンテナ実行。-dをつけることでコンテナがバックグランドで起動する。-pでホストのポート8001にきたリクエストをコンテナの80ポートに転送してくれる。

$ docker build -t nginx_test .
$ docker run -d -p 8001:80 nginx_test

↓結果
http://localhost:8001
スクリーンショット 2020-12-13 2.08.05.png

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?