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】コマンド一発でWebコンテンツが格納されたフォルダをhttp://localhost/でテストする。

Posted at

Dockerを用い、公式のnginxコンテナでやります。
何番煎じか分かりませんが、シンプルな記事が少なかったのでメモとして。

条件

Dockerが使える環境

  • コンテナ名(任意):nginx-container
  • Webコンテンツが格納されたフォルダ:/home/username/public_html
  • ポート番号:8080

テスト用に、/home/username/public_htmlに次のファイルを置いておく

index.html
<html>
<body>
index
</body>
</html>

コマンド

docker run \
    --name nginx-container \
    -v /home/username/public_html:/usr/share/nginx/html:ro \
    -p 8080:80 \
    -d \
    nginx:latest

結果

http://localhost:8080/
へアクセスし「index」と表示されれば成功です。

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?