1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【docker container】Nginx サーバーを起動し、ブラウザからアクセスする

Last updated at Posted at 2024-06-17

はじめに

Docker の docker container run コマンドを使って Nginx コンテナを起動し、ブラウザからアクセスする手順について記載します。

開発環境

開発環境は以下の通りです。

  • Windows 11
  • Docker Engine 26.1.1

Nginx サーバーを起動する

以下のコマンドで、Nginx サーバーをコンテナで起動します。

docker container run --rm --publish 8080:80 nginx
  • --rm : コンテナ停止時にコンテナを自動削除
  • --publish : コンテナの80番ポートをホストマシンの8080番ポートにマッピング

ブラウザからアクセスする

ブラウザで http://localhost:8080/ にアクセスすると、「Welcome to nginx!」が表示されます。

image.png

また、docker container ls でコンテナのポート情報を確認できます。今回は 8080 と 80 がマッピングしていることを確認できます。

image.png

参考

関連記事

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?