このページで解説している内容は、以下の YouTube 動画の解説で見ることができます。

Docker超入門:とりあえずDockerを動かしてみよう!Hello Worldから始める入門操作

とりあえずDockerを動かしてみよう!Hello Worldから始める入門操作

 Dockerを学ぶときに最初にやるべきことは「とにかく動かしてみる」ことです。難しい理屈をいきなり理解しようとするのではなく、実際に手を動かして動作を確認することで、全体像をつかみやすくなります。ここでは「Docker Desktop」を起動し、PowerShellで「Hello World」を動かす一連の流れを、図や表を交えて解説していきます。

Docker Desktopの起動

 Dockerを使うには「Docker Desktop」を起動しておく必要があります。これを立ち上げることで、バックグラウンドで Dockerエンジン(daemon) が動作し、コマンドでコンテナ操作が可能になります。

「Docker Desktop」を起動します。

ポイント

  • 「Docker Desktop」が起動していないと、コマンドはエラーになります。
  • GUIから イメージコンテナ の状況を確認できるので便利です。

dockerコマンドの基本

Dockerの操作は docker コマンドで行います。書式は以下のとおりです。

書式

docker [サブコマンド] [オプション] [対象]
項目説明
dockerDockerクライアントを呼び出すコマンド
サブコマンド実行したい操作(例:run, ps, images, version など)
オプション実行内容を細かく制御するための追加パラメータ
対象操作対象となるイメージ名やコンテナ名

Hello Worldを実行する

最初のサンプルとして、次のコマンドをPowerShellで入力します。

コマンド

docker run hello-world

実行結果

PS C:\Users\joeac> docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
17eec7bbc9d7: Pull complete
Digest: sha256:54e66cc1dd1fcb1c3c58bd8017914dbed8701e2d8c74d9262e26bd9cc1642d31
Status: Downloaded newer image for hello-world:latest

Hello from Docker! # ← この出力
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

(省略)

このコマンドの動きは以下の通りです。

  1. ローカルにhello-worldイメージがあるか確認
  2. なければDocker Hubからダウンロード
  3. そのイメージを元にコンテナを作成
  4. コンテナ内で実行ファイルを実行し、メッセージを出力

結果として「Hello from Docker!」というメッセージが表示されれば成功です。

docker runコマンドの詳細

項目説明
run指定したイメージから新しいコンテナを作成し、起動する。
hello-world利用するイメージ名。初学者向けのテスト用イメージ

主なオプション例

オプション説明
-it対話モードで実行(ターミナル入力可能)
-dバックグラウンドで実行
--nameコンテナに任意の名前をつける。

実行後の確認

Docker Desktopを開くと以下が確認できます。

Imagesタブ
「hello-world」が追加されているのを確認できます。

Containersタブ
 実行したコンテナが一覧表示され、name欄にランダムな名前(例:dazzling_spence)が付与されます。

その他の便利なコマンド

docker version

バージョン情報を確認します。

PS C:\Users\joeac> docker version
Client:
 Version:           28.4.0
 API version:       1.51
 Go version:        go1.24.7
 Git commit:        d8eb465
 Built:             Wed Sep  3 20:59:40 2025
 OS/Arch:           windows/amd64
 Context:           desktop-linux

(省略)
出力内容説明
ClientDockerクライアントのバージョン
ServerDockerエンジンのバージョン
APIDocker APIのバージョン

docker system info

システムの詳細情報を確認します。

PS C:\Users\joeac> docker system info
Client:
 Version:    28.4.0
 Context:    desktop-linux
 Debug Mode: false
 Plugins:
  ai: Docker AI Agent - Ask Gordon (Docker Inc.)
    Version:  v1.9.11
    Path:     C:\Program Files\Docker\cli-plugins\docker-ai.exe

(省略)

 CPU数、メモリ、ストレージドライバ、ネットワークモードなど、かなり多くの情報が表示されます。最初は「へぇ、こういう情報が取れるんだ」くらいでOKです。

docker system df

ディスク使用量を確認します。

PS C:\Users\joeac> docker system df
TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          1         1         65.45kB   45.11kB (68%)
Containers      1         0         4.096kB   4.096kB (100%)
Local Volumes   0         0         0B        0B
Build Cache     0         0         0B        0B
項目説明
Imagesダウンロードしたイメージのサイズ
Containers作成されたコンテナ数と使用量
Volumesボリュームの使用量
Build Cacheビルド時のキャッシュ容量

まとめ

 「docker run hello-world」を実行することで、Dockerが正しく動作しているかを確認できました。ここまでで Dockerの準備完了 です。あとは本格的にコンテナを使った操作やアプリ実行に進んでいけます。まずはHello Worldで一歩を踏み出すことが、Docker学習の入り口になります。