11
3

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 5 years have passed since last update.

Docker + NGINXにログインする方法

Last updated at Posted at 2020-01-30

Docker Compose で起動したNGINXにターミナルでログインする方法について明記します。

まず、作成済みのコンテナイメージをビルドして、コンテナイメージを起動します。
docker-compose ~を実行できるディレクトリは、 docker-compose.yml(Composefile)のある場所です。

Terminal(コンテナイメージのビルドと起動)
$ docker-compose build
$ docker-compose up -d
(下記コマンドの様に省略可)
$ docker-compose up -d --build

と入力します。

イメージ起動後、ps コマンドでイメージの起動状態を確認します。
(「指定されたパスが見つかりません。」は気にしなくていいです。)

$ docker-compose ps
指定されたパスが見つかりません。
 Name                Command              State           Ports
------------------------------------------------------------------------
nginx     nginx -g daemon off;            Up      0.0.0.0:80->80/tcp
php-fpm   docker-php-entrypoint php-fpm   Up      0.0.0.0:9000->9000/tcp

Name の列に「nginx」と「php-fpm」という名前のイメージが起動していることが分かります。
State が「Up」となっていれば、起動中です。「Exit」となっている場合は、停止しています。

では、本題のログインコマンドは以下の様になります。

$ docker exec -it nginx /bin/sh
/ # 

ログアウトは exitコマンドを実行すればいいです。
以上です。

11
3
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
11
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?