このページで解説している内容は、以下の YouTube 動画の解説で見ることができます。
【Docker入門】とりあえずDockerを動かしてみる

「Docker Desktop」をインストールすると、dockerコマンドが使えるようになります。dockerコマンドの後ろに様々なオプションを指定して、操作していくようになります。
dockerって何者なんだ!って初めて学ぶ方は、思うかもしれません。
ここでは、難しい話は置いておいて、とりあえず、Dockerを動かしてみて、Dockerがどういったものなのかを、全体像を把握していきます。
ITに関することを初めて学習する際には、最初のサンプルが用意されていて、それを動かすところから始めていくかと思います。このDockerにもサンプルが用意されています。
ITでは、おなじみの「Hello World」がDockerにも用意されています。
ITの学習では、おなじみの「Hello World」を表示するという儀式からDockerの操作を学習していくことにします。
1.「Docker Desktop」を起動します。
Dockerを手っ取り早く動作させたいなら、「Docker Desktop」を起動しておく必要があります。
また、「Docker Desktop」を起動しておくと、取得しているイメージやコンテナの状況を把握しやすくなるので、Dockerを操作する際は、「Docker Desktop」を起動しておくことをお勧めします。

2.PowerShellでdockerコマンドを実行する。
PowerShellで次のdockerコマンドを実行します。
・「docker run hello-world」と入力します。
PowerShell 7.4.1
PS C:\Users\joeac> docker run hello-world
以下のように表示されたら、「Docker Desktop」がちゃんとインストールされていることを意味します。
PS C:\Users\joeac> docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete
Digest: sha256:d000bc569937abbe195e20322a0bde6b2922d805332fd6d8a68b19f524b7d21d
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
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
上の8行目ですが、「Hello from Docker!」というメッセージが出力されました。
3.「Docker Desktop」で状況を確認する。
「Docker Desktop」で状況を確認します。
・「Docker Desktop」の「Images」タブを確認します。
「hello-world」というイメージがあることが確認できます。

・「Docker Desktop」の「Containers」タブを確認します。
name欄に「dazzling_spence」と表示されています。これは、あだ名のようなもので、実行する度に違う名前となっている可能性があります。
image欄には「hello-world」と表示されています。

4.その他のDockerコマンド
コマンド、1つで「Hello from Docker!」が表示されました。このまま、終わるのも、あっけないので、ついでに、その他のコマンドも試してみましょう。
4.1 「docker version」コマンド
バージョン情報を確認します。
・「docker version」コマンドを実行します。
PS C:\Users\joeac> docker version
Client:
Cloud integration: v1.0.35+desktop.5
Version: 24.0.6
API version: 1.43
Go version: go1.20.7
Git commit: ed223bc
Built: Mon Sep 4 12:32:48 2023
OS/Arch: windows/amd64
Context: default
Server: Docker Desktop 4.25.2 (129061)
Engine:
Version: 24.0.6
API version: 1.43 (minimum version 1.12)
Go version: go1.20.7
Git commit: 1a79695
Built: Mon Sep 4 12:32:16 2023
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.22
GitCommit: 8165feabfdfe38c65b599c4993d227328c231fca
runc:
Version: 1.1.8
GitCommit: v1.1.8-0-g82f18fe
docker-init:
Version: 0.19.0
4.2 「docker systemi info」コマンド
・実行環境を確認します。
小難しい情報が表示されますが、こんな感じのものが出力されるんだと、眺めていただければ、大丈夫です。
PS C:\Users\joeac> docker system info
Client:
Version: 24.0.6
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.11.2-desktop.5
Path: C:\Program Files\Docker\cli-plugins\docker-buildx.exe
compose: Docker Compose (Docker Inc.)
Version: v2.23.0-desktop.1
Path: C:\Program Files\Docker\cli-plugins\docker-compose.exe
dev: Docker Dev Environments (Docker Inc.)
Version: v0.1.0
Path: C:\Program Files\Docker\cli-plugins\docker-dev.exe
extension: Manages Docker extensions (Docker Inc.)
Version: v0.2.20
Path: C:\Program Files\Docker\cli-plugins\docker-extension.exe
init: Creates Docker-related starter files for your project (Docker Inc.)
Version: v0.1.0-beta.9
Path: C:\Program Files\Docker\cli-plugins\docker-init.exe
sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
Version: 0.6.0
Path: C:\Program Files\Docker\cli-plugins\docker-sbom.exe
scan: Docker Scan (Docker Inc.)
Version: v0.26.0
Path: C:\Program Files\Docker\cli-plugins\docker-scan.exe
scout: Docker Scout (Docker Inc.)
Version: v1.0.9
Path: C:\Program Files\Docker\cli-plugins\docker-scout.exe
Server:
Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 1
Server Version: 24.0.6
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 8165feabfdfe38c65b599c4993d227328c231fca
runc version: v1.1.8-0-g82f18fe
init version: de40ad0
Security Options:
seccomp
Profile: unconfined
Kernel Version: 5.15.133.1-microsoft-standard-WSL2
Operating System: Docker Desktop
OSType: linux
Architecture: x86_64
CPUs: 20
Total Memory: 15.5GiB
Name: OMEN25L
ID: 9ddb464f-6e4e-4152-b714-5fda2e7013cd
Docker Root Dir: /var/lib/docker
Debug Mode: false
HTTP Proxy: http.docker.internal:3128
HTTPS Proxy: http.docker.internal:3128
No Proxy: hubproxy.docker.internal
Experimental: false
Insecure Registries:
hubproxy.docker.internal:5555
127.0.0.0/8
Live Restore Enabled: false
WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support
WARNING: daemon is not using the default seccomp profile
4.3 「docker system df」コマンド
・ディスクの利用状況を確認します。
PS C:\Users\joeac> docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 1 1 13.26kB 0B (0%)
Containers 1 0 0B 0B
Local Volumes 0 0 0B 0B
Build Cache 74 0 438.4MB 438.4MB
ディスクの利用状況が確認できます。
まとめ
とりあえず、Dockerを操作してみました。
これで、Dockerを学ぶ環境が整いました。ここから、Dockerの本格的な操作を始めていきます。