hello-worldイメージ

Last-modified: 2020-05-23 (土) 00:48:28

dockerでは以下の流れ

  • dockerhubからイメージをダウンロード(pull)
  • ダウンロードしたイメージをもとにコンテナを作る(run)

dockerのバージョン確認

コマンドプロンプト/powershellで以下のコマンドを実行すると、dockerのバージョンが確認できる。

docker --version


「hello-world」イメージのダウンロードと実行

以下のコマンドで、「hello world」イメージをダウンロード・実行する。

docker run hello-world

※ダウンロードだけの場合は

docker pull hello-world

イメージの確認

以下のコマンドで、ローカル環境内に「hello-world」イメージがダウンロードされれいるか確認する。

docker image ls

出力例

docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              bf756fb1ae65        4 months ago        13.3kB

以下のコマンドで、すべてのコンテナを表示し、hello-worldが存在することを確認する。

docker ps -all

出力例

docker ps -all
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
c3e781364a44        hello-world         "/hello"            41 seconds ago      Exited (0) 39 seconds ago                       kind_cray

※STATUSがExietedになっているのは、hello-worldイメージはhello world」を実行して終わるイメージだから。

イメージの削除

docker rm [NAMES]
docker rm [CONTAINER ID]