My開発メモ

Dockerコンテナをpullしてrunして削除する

php:7.4.30-apache を使う。

以下のコンテナを使う。

$ docker pull php:7.4.30-apache

イメージがダウンロードされるので、以下のコマンドでコンテナを起動する。

$ docker run --name php -d php:7.4.30-apache

このコンテナに php という名前をつけて、 -d オプションによりバックグラウンドで動かす。

-dオプションをつけなければ、以下のようなメッセージが表示される。

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
[Wed Aug 10 23:11:08.037533 2022] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.54 (Debian) PHP/7.4.30 configured -- resuming normal operations
[Wed Aug 10 23:11:08.037569 2022] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'

別ターミナルで、以下のコマンドを実行することで、そのコンテナにログインできる。

$ docker exec -it php /bin/bash

コンテナを止める。

$ docker stop php

コンテナを削除する。

$ docker rm php

コンテナ・イメージの削除は、以下。

$ docker images

で、コンテナのイメージを調べて、

$ docker rmi <IMAGE ID>

カテゴリー: Docker, memo

タグ: Docker, pull, run, stop

カウント: 179