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?

Dockerハンズオン - 基本動作確認

Last updated at Posted at 2025-05-26

こんにちは。
Docker?コンテナ?状態なので、入門レベルのハンズオンから始めていきます。

前提

・VSCodeがインストールされている。

Docker Desktopのインストール

以下のページからDocker Desktopをインストールして、登録します。
https://www.docker.com/ja-jp/products/docker-desktop/

登録が終わると以下の画面が表示されます。
image.png

Dockerイメージの取得

Dockerから用意されているテスト用のイメージ「hello-world」を取得していきます。
イメージ取得にはpullコマンドを使用します。

VSCodeで以下のコマンド実行します。
docker pull hello-world

image.png

次に、Dockerイメージを一覧表示させるコマンドを実行します。
先程取得したイメージ「hello-world」が表示されるはずです。
docker image ls
ls=listの意味

先ほど取得したイメージ「hello-world」が表示されていますね。

image.png

Dockerイメージからコンテナを起動

取得したイメージ「hello-world」から、コンテナを起動させます。
コンテナ起動の際はcontainer runコマンドを使用します。

以下コマンドを実行します。
docker container run hello-world

image.png

Hello from Docker!
の文字列が表示されており、成功です。

現在ローカルにあるコンテナを一覧表示させるコマンドを実行します。
docker container ls -a
※optionの補足 -a=--all 
allで停止中のコンテ含めてすべて表示させます。先ほどのコンテナ起動してメッセージ表示後、コンテナは自動で停止されます。

image.png

Dockerコンテナの削除

コンテナ削除のコマンドを実行します。
docker container rm <container ID>

先程コンテナ一覧表示した際にcontainer IDが記載されているので、コピペします。

image.png

Dockerイメージの削除

イメージ削除のコマンドを実行します。
docker image rm hello-world

その後lsコマンドで一覧を表示すると、hello-worldが表示されなくなりました。
削除されていることがわかります。

image.png

まとめ

シンプルなコマンドで基本動作ができることがわかりました。
想像していたより簡単でした。
引き続き学習を継続していきます。

参考

Cloudtech AWSレッスン動画コース 【Docker-3】Dockerの動作確認

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?