Windows 10 Home、VirtualBox、CentOS 7の環境でCentOS 7にDockerをインストールする
記事時点:2020年4月15日
注意
- この記事時点では WSL 2 による Docker Desktop for Windows Home がまだ出てないので扱っていません。
- Docker Toolbox も扱っていません。
やること
- Dockerを試したい
- 使っている端末がWin10 HomeなのでDocker Desktop for Windowsが使えない
- なので、Oracle VM VirtualBox の上にCentOSを用意してそこにDockerをインストールする
- Docker公式ドキュメントに沿って丁寧に行う。
- インストールするまで。
最終的な各ソフトのバージョン
Windows
Windows 10 Home バージョン 1909 OSビルド18363.720。
確認方法は「設定」→「システム」→「バージョン情報」で表示、または「ファイル名を指定して実行」で winver コマンドで表示する。
VirtualBox
6.1.4r136177
CentOS
7.7
$ cat /etc/redhat-release CentOS Linux release 7.7.1908 (Core)
Docker
19.03
$ docker --version Docker version 19.03.8, build afacb8b
この記事のために事前にやること
- VirtualBoxをインストールする。
- 以降の記事にある選定したCentOSのバージョンをインストールして、yumなどのアップデートコマンドがインターネットに繋がるようにする。
この記事では扱わないこと
CentOSのインストール方法は扱わない。
使用OSなどの選定
Docker Desktop on WIndows は使えるかどうか
公式ドキュメントの Install Docker Desktop on Windows を確認する。
System Requirements の部分に必要なものが書いてある。
Install Docker Desktop on Windows | Docker Documentation
・Windows 10 64-bit: Pro, Enterprise, or Education (Build 15063 or later).
・Hyper-V and Containers Windows features must be enabled.
- Windows 10 64-bitでPro, Enterprise, Education エディションが必要。
- Hyper-V の機能が有効化、 Windows Containers が有効化している必要あり。
とあるので、Windows 10 Homeにはインストールできない。このためLinuxとしてCentOSに入れる。
CentOS のバージョンはどれを使うか
公式ドキュメントに CentOS 7のメンテナンスバージョンが必要と書いてある。
Install Docker Engine on CentOS | Docker Documentation
To install Docker Engine, you need a maintained version of CentOS 7. Archived versions aren’t supported or tested.
また CentOS 8 は、元となる RHEL 8が Docker を削除して podman に変わっていることからサポートされていない。
検索すると containerd.io を入れて強制的にインストールなどの記事が出てくる。 このため、ドキュメント推奨の CentOS 7 で実施する。
インストールしていく
以降はCentOS上で操作する。
yum-config-manager コマンドを使えるようにする
Install Docker Engine on CentOS | Docker Documentation
Install the yum-utils package (which provides the yum-config-manager utility) and set up the stable repository.
まず yum-utilsをインストールして yum-config-manager
コマンドを使えるようにする。
・yumでインストールするためにrootにスイッチ。sudoが使えるユーザーならやらなくてよい。 $ su - パスワード: # ・yum-utils パッケージの情報を表示。今回はインストール済みだった # yum info yum-utils インストール済みパッケージ 名前 : yum-utils アーキテクチャー : noarch バージョン : 1.1.31 リリース : 52.el7 容量 : 337 k リポジトリー : installed 提供元リポジトリー : anaconda 要約 : Utilities based around the yum package manager URL : http://yum.baseurl.org/download/yum-utils/ ライセンス : GPLv2+ 説明 : yum-utils is a collection of utilities and examples for the yum package : manager. It includes utilities by different authors that make yum easier and : more powerful to use. These tools include: debuginfo-install, : find-repos-of-install, needs-restarting, package-cleanup, repoclosure, : repodiff, repo-graph, repomanage, repoquery, repo-rss, reposync, : repotrack, show-installed, show-changed-rco, verifytree, yumdownloader, : yum-builddep, yum-complete-transaction, yum-config-manager, yum-debug-dump, : yum-debug-restore and yum-groups-manager.
Dockerのyumリポジトリを登録する。
マニュアルではインストールする方法がいくつか提示されているが、リポジトリを登録してインストールする方法を取る。
Install Docker Engine on CentOS | Docker Documentation
Before you install Docker Engine for the first time on a new host machine, you need to set up the Docker repository. Afterward, you can install and update Docker from the repository.
# yum-config-manager \ > --add-repo \ > https://download.docker.com/linux/centos/docker-ce.repo 読み込んだプラグイン:fastestmirror, langpacks adding repo from: https://download.docker.com/linux/centos/docker-ce.repo grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo repo saved to /etc/yum.repos.d/docker-ce.repo
/etc/yum.repos.d/docker-ce.repo
が登録された。中身を確認する。
# cat /etc/yum.repos.d/docker-ce.repo [docker-ce-stable] name=Docker CE Stable - $basearch baseurl=https://download.docker.com/linux/centos/7/$basearch/stable enabled=1 gpgcheck=1 gpgkey=https://download.docker.com/linux/centos/gpg [docker-ce-stable-debuginfo] name=Docker CE Stable - Debuginfo $basearch baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/stable enabled=0 gpgcheck=1 gpgkey=https://download.docker.com/linux/centos/gpg [docker-ce-stable-source] name=Docker CE Stable - Sources baseurl=https://download.docker.com/linux/centos/7/source/stable enabled=0 gpgcheck=1 gpgkey=https://download.docker.com/linux/centos/gpg [docker-ce-edge] name=Docker CE Edge - $basearch baseurl=https://download.docker.com/linux/centos/7/$basearch/edge enabled=0 gpgcheck=1 gpgkey=https://download.docker.com/linux/centos/gpg [docker-ce-edge-debuginfo] name=Docker CE Edge - Debuginfo $basearch baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/edge enabled=0 gpgcheck=1 gpgkey=https://download.docker.com/linux/centos/gpg [docker-ce-edge-source] name=Docker CE Edge - Sources baseurl=https://download.docker.com/linux/centos/7/source/edge enabled=0 gpgcheck=1 gpgkey=https://download.docker.com/linux/centos/gpg [docker-ce-test] name=Docker CE Test - $basearch baseurl=https://download.docker.com/linux/centos/7/$basearch/test enabled=0 gpgcheck=1 gpgkey=https://download.docker.com/linux/centos/gpg [docker-ce-test-debuginfo] name=Docker CE Test - Debuginfo $basearch baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/test enabled=0 gpgcheck=1 gpgkey=https://download.docker.com/linux/centos/gpg [docker-ce-test-source] name=Docker CE Test - Sources baseurl=https://download.docker.com/linux/centos/7/source/test enabled=0 gpgcheck=1 gpgkey=https://download.docker.com/linux/centos/gpg [docker-ce-nightly] name=Docker CE Nightly - $basearch baseurl=https://download.docker.com/linux/centos/7/$basearch/nightly enabled=0 gpgcheck=1 gpgkey=https://download.docker.com/linux/centos/gpg [docker-ce-nightly-debuginfo] name=Docker CE Nightly - Debuginfo $basearch baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/nightly enabled=0 gpgcheck=1 gpgkey=https://download.docker.com/linux/centos/gpg [docker-ce-nightly-source] name=Docker CE Nightly - Sources baseurl=https://download.docker.com/linux/centos/7/source/nightly enabled=0 gpgcheck=1 gpgkey=https://download.docker.com/linux/centos/gpg
enabled=1
となっているのが有効なyumリポジトリなので、docker-ce-stable だけが有効になっている。
Docker Engine をインストールする
最新バージョンをインストールする。 入れるパッケージは docker-ce, docker-ce-cli, containerd.io の3つ。
それぞれ何のパッケージかを確認する。 # yum info docker-ce 利用可能なパッケージ 名前 : docker-ce アーキテクチャー : x86_64 エポック : 3 バージョン : 19.03.8 リリース : 3.el7 容量 : 25 M リポジトリー : docker-ce-stable/x86_64 要約 : The open-source application container engine URL : https://www.docker.com ライセンス : ASL 2.0 説明 : Docker is a product for you to build, ship and run any application as a : lightweight container. : : Docker containers are both hardware-agnostic and platform-agnostic. This means : they can run anywhere, from your laptop to the largest cloud compute instance and : everything in between - and they don't require you to use a particular : language, framework or packaging system. That makes them great building blocks : for deploying and scaling web apps, databases, and backend services without : depending on a particular stack or provider.
# yum info docker-ce-cli 利用可能なパッケージ 名前 : docker-ce-cli アーキテクチャー : x86_64 エポック : 1 バージョン : 19.03.8 リリース : 3.el7 容量 : 40 M リポジトリー : docker-ce-stable/x86_64 要約 : The open-source application container engine URL : https://www.docker.com ライセンス : ASL 2.0 説明 : Docker is is a product for you to build, ship and run any application as a : lightweight container. : : Docker containers are both hardware-agnostic and platform-agnostic. This means : they can run anywhere, from your laptop to the largest cloud compute instance and : everything in between - and they don't require you to use a particular : language, framework or packaging system. That makes them great building blocks : for deploying and scaling web apps, databases, and backend services without : depending on a particular stack or provider.
# yum info containerd.io 利用可能なパッケージ 名前 : containerd.io アーキテクチャー : x86_64 バージョン : 1.2.13 リリース : 3.1.el7 容量 : 23 M リポジトリー : docker-ce-stable/x86_64 要約 : An industry-standard container runtime URL : https://containerd.io ライセンス : ASL 2.0 説明 : containerd is an industry-standard container runtime with an emphasis on : simplicity, robustness and portability. It is available as a daemon for Linux : and Windows, which can manage the complete container lifecycle of its host : system: image transfer and storage, container execution and supervision, : low-level storage and network attachments, etc.
これらを入れろとあるので、インストールする。
# yum install docker-ce docker-ce-cli containerd.io 依存性を解決しました ============================================================ Package アーキテクチャー バージョン リポジトリー 容量 ============================================================ containerd.io x86_64 1.2.13-3.1.el7 docker-ce-stable 23 M docker-ce x86_64 3:19.03.8-3.el7 docker-ce-stable 25 M docker-ce-cli x86_64 1:19.03.8-3.el7 docker-ce-stable 40 M 依存性関連でのインストールをします: container-selinux noarch :2.107-3.el7 extras 39 k トランザクションの要約 ============================================================ インストール 3 パッケージ (+1 個の依存関係のパッケージ) 総ダウンロード容量: 87 M インストール容量: 363 M Is this ok [y/d/N]:
依存性関連でSELinux関連のパッケージも入るみたい。
yを入力して続行。
Is this ok [y/d/N]: y Downloading packages: ・・・・ https://download.docker.com/linux/centos/gpg から鍵を取得中です。 Importing GPG key 0x621E9F35: Userid : "Docker Release (CE rpm) <docker@docker.com>" Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35 From : https://download.docker.com/linux/centos/gpg 上記の処理を行います。よろしいでしょうか? [y/N]
GPGキーの確認が入る。ドキュメントに以下のようにあって、Fingerprint の欄と一致しているのでOKだろう。
If prompted to accept the GPG key, verify that the fingerprint matches
060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
, and if so, accept it.
上記の処理を行います。よろしいでしょうか? [y/N]y ・・・・ インストール: containerd.io.x86_64 0:1.2.13-3.1.el7 docker-ce.x86_64 3:19.03.8-3.el7 docker-ce-cli.x86_64 1:19.03.8-3.el7 依存性関連をインストールしました: container-selinux.noarch 2:2.107-3.el7 完了しました!
これでインストールはできた。
パッケージによって何がインストールされたのか
何が入ったのかを repoquery --list
コマンドで見ていく。
docker-ce
# repoquery --list docker-ce /usr/bin/docker-init /usr/bin/docker-proxy /usr/bin/dockerd /usr/lib/systemd/system/docker.service /usr/lib/systemd/system/docker.socket /var/lib/docker-engine/distribution_based_engine.json
実行コマンドやsystemd用のものなど。
distribution_based_engine.jsonは何だろう?
# cat /var/lib/docker-engine/distribution_based_engine.json {"platform":"Docker Engine - Community","engine_image":"engine-community-dm","containerd_min_version":"1.2.0-beta.1","runtime":"host_install"}
そこまで重要な情報ではないか?
docker-ce-cli
# repoquery --list docker-ce-cli /usr/bin/docker /usr/libexec/docker/cli-plugins/docker-app /usr/libexec/docker/cli-plugins/docker-buildx /usr/share/bash-completion/completions/docker /usr/share/doc/docker-ce-cli-19.03.8 /usr/share/doc/docker-ce-cli-19.03.8/LICENSE /usr/share/doc/docker-ce-cli-19.03.8/MAINTAINERS /usr/share/doc/docker-ce-cli-19.03.8/NOTICE /usr/share/doc/docker-ce-cli-19.03.8/README.md /usr/share/fish/vendor_completions.d/docker.fish /usr/share/man/man1/docker-attach.1.gz /usr/share/man/man1/docker-build.1.gz /usr/share/man/man1/docker-builder-build.1.gz /usr/share/man/man1/docker-builder-prune.1.gz /usr/share/man/man1/docker-builder.1.gz /usr/share/man/man1/docker-checkpoint-create.1.gz /usr/share/man/man1/docker-checkpoint-ls.1.gz /usr/share/man/man1/docker-checkpoint-rm.1.gz /usr/share/man/man1/docker-checkpoint.1.gz /usr/share/man/man1/docker-commit.1.gz /usr/share/man/man1/docker-config-create.1.gz /usr/share/man/man1/docker-config-inspect.1.gz /usr/share/man/man1/docker-config-ls.1.gz /usr/share/man/man1/docker-config-rm.1.gz /usr/share/man/man1/docker-config.1.gz /usr/share/man/man1/docker-container-attach.1.gz /usr/share/man/man1/docker-container-commit.1.gz /usr/share/man/man1/docker-container-cp.1.gz /usr/share/man/man1/docker-container-create.1.gz /usr/share/man/man1/docker-container-diff.1.gz /usr/share/man/man1/docker-container-exec.1.gz /usr/share/man/man1/docker-container-export.1.gz /usr/share/man/man1/docker-container-inspect.1.gz /usr/share/man/man1/docker-container-kill.1.gz /usr/share/man/man1/docker-container-logs.1.gz /usr/share/man/man1/docker-container-ls.1.gz /usr/share/man/man1/docker-container-pause.1.gz /usr/share/man/man1/docker-container-port.1.gz /usr/share/man/man1/docker-container-prune.1.gz /usr/share/man/man1/docker-container-rename.1.gz /usr/share/man/man1/docker-container-restart.1.gz /usr/share/man/man1/docker-container-rm.1.gz /usr/share/man/man1/docker-container-run.1.gz /usr/share/man/man1/docker-container-start.1.gz /usr/share/man/man1/docker-container-stats.1.gz /usr/share/man/man1/docker-container-stop.1.gz /usr/share/man/man1/docker-container-top.1.gz /usr/share/man/man1/docker-container-unpause.1.gz /usr/share/man/man1/docker-container-update.1.gz /usr/share/man/man1/docker-container-wait.1.gz /usr/share/man/man1/docker-container.1.gz /usr/share/man/man1/docker-context-create.1.gz /usr/share/man/man1/docker-context-export.1.gz /usr/share/man/man1/docker-context-import.1.gz /usr/share/man/man1/docker-context-inspect.1.gz /usr/share/man/man1/docker-context-ls.1.gz /usr/share/man/man1/docker-context-rm.1.gz /usr/share/man/man1/docker-context-update.1.gz /usr/share/man/man1/docker-context-use.1.gz /usr/share/man/man1/docker-context.1.gz /usr/share/man/man1/docker-cp.1.gz /usr/share/man/man1/docker-create.1.gz /usr/share/man/man1/docker-deploy.1.gz /usr/share/man/man1/docker-diff.1.gz /usr/share/man/man1/docker-engine-activate.1.gz /usr/share/man/man1/docker-engine-check.1.gz /usr/share/man/man1/docker-engine-update.1.gz /usr/share/man/man1/docker-engine.1.gz /usr/share/man/man1/docker-events.1.gz /usr/share/man/man1/docker-exec.1.gz /usr/share/man/man1/docker-export.1.gz /usr/share/man/man1/docker-history.1.gz /usr/share/man/man1/docker-image-build.1.gz /usr/share/man/man1/docker-image-history.1.gz /usr/share/man/man1/docker-image-import.1.gz /usr/share/man/man1/docker-image-inspect.1.gz /usr/share/man/man1/docker-image-load.1.gz /usr/share/man/man1/docker-image-ls.1.gz /usr/share/man/man1/docker-image-prune.1.gz /usr/share/man/man1/docker-image-pull.1.gz /usr/share/man/man1/docker-image-push.1.gz /usr/share/man/man1/docker-image-rm.1.gz /usr/share/man/man1/docker-image-save.1.gz /usr/share/man/man1/docker-image-tag.1.gz /usr/share/man/man1/docker-image.1.gz /usr/share/man/man1/docker-images.1.gz /usr/share/man/man1/docker-import.1.gz /usr/share/man/man1/docker-info.1.gz /usr/share/man/man1/docker-inspect.1.gz /usr/share/man/man1/docker-kill.1.gz /usr/share/man/man1/docker-load.1.gz /usr/share/man/man1/docker-login.1.gz /usr/share/man/man1/docker-logout.1.gz /usr/share/man/man1/docker-logs.1.gz /usr/share/man/man1/docker-manifest-annotate.1.gz /usr/share/man/man1/docker-manifest-create.1.gz /usr/share/man/man1/docker-manifest-inspect.1.gz /usr/share/man/man1/docker-manifest-push.1.gz /usr/share/man/man1/docker-manifest.1.gz /usr/share/man/man1/docker-network-connect.1.gz /usr/share/man/man1/docker-network-create.1.gz /usr/share/man/man1/docker-network-disconnect.1.gz /usr/share/man/man1/docker-network-inspect.1.gz /usr/share/man/man1/docker-network-ls.1.gz /usr/share/man/man1/docker-network-prune.1.gz /usr/share/man/man1/docker-network-rm.1.gz /usr/share/man/man1/docker-network.1.gz /usr/share/man/man1/docker-node-demote.1.gz /usr/share/man/man1/docker-node-inspect.1.gz /usr/share/man/man1/docker-node-ls.1.gz /usr/share/man/man1/docker-node-promote.1.gz /usr/share/man/man1/docker-node-ps.1.gz /usr/share/man/man1/docker-node-rm.1.gz /usr/share/man/man1/docker-node-update.1.gz /usr/share/man/man1/docker-node.1.gz /usr/share/man/man1/docker-pause.1.gz /usr/share/man/man1/docker-plugin-create.1.gz /usr/share/man/man1/docker-plugin-disable.1.gz /usr/share/man/man1/docker-plugin-enable.1.gz /usr/share/man/man1/docker-plugin-inspect.1.gz /usr/share/man/man1/docker-plugin-install.1.gz /usr/share/man/man1/docker-plugin-ls.1.gz /usr/share/man/man1/docker-plugin-push.1.gz /usr/share/man/man1/docker-plugin-rm.1.gz /usr/share/man/man1/docker-plugin-set.1.gz /usr/share/man/man1/docker-plugin-upgrade.1.gz /usr/share/man/man1/docker-plugin.1.gz /usr/share/man/man1/docker-port.1.gz /usr/share/man/man1/docker-ps.1.gz /usr/share/man/man1/docker-pull.1.gz /usr/share/man/man1/docker-push.1.gz /usr/share/man/man1/docker-rename.1.gz /usr/share/man/man1/docker-restart.1.gz /usr/share/man/man1/docker-rm.1.gz /usr/share/man/man1/docker-rmi.1.gz /usr/share/man/man1/docker-run.1.gz /usr/share/man/man1/docker-save.1.gz /usr/share/man/man1/docker-search.1.gz /usr/share/man/man1/docker-secret-create.1.gz /usr/share/man/man1/docker-secret-inspect.1.gz /usr/share/man/man1/docker-secret-ls.1.gz /usr/share/man/man1/docker-secret-rm.1.gz /usr/share/man/man1/docker-secret.1.gz /usr/share/man/man1/docker-service-create.1.gz /usr/share/man/man1/docker-service-inspect.1.gz /usr/share/man/man1/docker-service-logs.1.gz /usr/share/man/man1/docker-service-ls.1.gz /usr/share/man/man1/docker-service-ps.1.gz /usr/share/man/man1/docker-service-rm.1.gz /usr/share/man/man1/docker-service-rollback.1.gz /usr/share/man/man1/docker-service-scale.1.gz /usr/share/man/man1/docker-service-update.1.gz /usr/share/man/man1/docker-service.1.gz /usr/share/man/man1/docker-stack-deploy.1.gz /usr/share/man/man1/docker-stack-ls.1.gz /usr/share/man/man1/docker-stack-ps.1.gz /usr/share/man/man1/docker-stack-rm.1.gz /usr/share/man/man1/docker-stack-services.1.gz /usr/share/man/man1/docker-stack.1.gz /usr/share/man/man1/docker-start.1.gz /usr/share/man/man1/docker-stats.1.gz /usr/share/man/man1/docker-stop.1.gz /usr/share/man/man1/docker-swarm-ca.1.gz /usr/share/man/man1/docker-swarm-init.1.gz /usr/share/man/man1/docker-swarm-join-token.1.gz /usr/share/man/man1/docker-swarm-join.1.gz /usr/share/man/man1/docker-swarm-leave.1.gz /usr/share/man/man1/docker-swarm-unlock-key.1.gz /usr/share/man/man1/docker-swarm-unlock.1.gz /usr/share/man/man1/docker-swarm-update.1.gz /usr/share/man/man1/docker-swarm.1.gz /usr/share/man/man1/docker-system-df.1.gz /usr/share/man/man1/docker-system-events.1.gz /usr/share/man/man1/docker-system-info.1.gz /usr/share/man/man1/docker-system-prune.1.gz /usr/share/man/man1/docker-system.1.gz /usr/share/man/man1/docker-tag.1.gz /usr/share/man/man1/docker-top.1.gz /usr/share/man/man1/docker-trust-inspect.1.gz /usr/share/man/man1/docker-trust-key-generate.1.gz /usr/share/man/man1/docker-trust-key-load.1.gz /usr/share/man/man1/docker-trust-key.1.gz /usr/share/man/man1/docker-trust-revoke.1.gz /usr/share/man/man1/docker-trust-sign.1.gz /usr/share/man/man1/docker-trust-signer-add.1.gz /usr/share/man/man1/docker-trust-signer-remove.1.gz /usr/share/man/man1/docker-trust-signer.1.gz /usr/share/man/man1/docker-trust.1.gz /usr/share/man/man1/docker-unpause.1.gz /usr/share/man/man1/docker-update.1.gz /usr/share/man/man1/docker-version.1.gz /usr/share/man/man1/docker-volume-create.1.gz /usr/share/man/man1/docker-volume-inspect.1.gz /usr/share/man/man1/docker-volume-ls.1.gz /usr/share/man/man1/docker-volume-prune.1.gz /usr/share/man/man1/docker-volume-rm.1.gz /usr/share/man/man1/docker-volume.1.gz /usr/share/man/man1/docker-wait.1.gz /usr/share/man/man1/docker.1.gz /usr/share/man/man5/Dockerfile.5.gz /usr/share/man/man5/docker-config-json.5.gz /usr/share/man/man8/dockerd.8.gz /usr/share/zsh/vendor-completions/_docker
docker コマンドとmanかな。
containerd.io
# repoquery --list containerd.io /etc/containerd /etc/containerd/config.toml /usr/bin/containerd /usr/bin/containerd-shim /usr/bin/ctr /usr/bin/runc /usr/lib/systemd/system/containerd.service /usr/share/doc/containerd.io-1.2.13 /usr/share/doc/containerd.io-1.2.13/README.md /usr/share/licenses/containerd.io-1.2.13 /usr/share/licenses/containerd.io-1.2.13/LICENSE /usr/share/man/man1/containerd-config.1 /usr/share/man/man1/containerd.1 /usr/share/man/man1/ctr.1 /usr/share/man/man5/containerd-config.toml.5
containerd とその設定ファイル config.toml などっぽい。
Docker を起動する
# systemctl start docker # ・コマンド終了後に何も出てこないので、statusで起動確認。 # systemctl status docker ● docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled) Active: active (running) since ***日付*** Docs: https://docs.docker.com Main PID: 31970 (dockerd) Tasks: 8 Memory: 40.8M CGroup: /system.slice/docker.service mq31970 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock 4月 16 03:16:21 station.example.com dockerd[31970]: time="2020-04-16T03:16:21.705665998+09:00" level...rpc 4月 16 03:16:21 station.example.com dockerd[31970]: time="2020-04-16T03:16:21.705680091+09:00" level...rpc 4月 16 03:16:21 station.example.com dockerd[31970]: time="2020-04-16T03:16:21.705689390+09:00" level...rpc 4月 16 03:16:21 station.example.com dockerd[31970]: time="2020-04-16T03:16:21.764035527+09:00" level...t." 4月 16 03:16:22 station.example.com dockerd[31970]: time="2020-04-16T03:16:22.209702962+09:00" level...ss" 4月 16 03:16:22 station.example.com dockerd[31970]: time="2020-04-16T03:16:22.440436650+09:00" level...e." 4月 16 03:16:22 station.example.com dockerd[31970]: time="2020-04-16T03:16:22.479349000+09:00" level...3.8 4月 16 03:16:22 station.example.com dockerd[31970]: time="2020-04-16T03:16:22.479767598+09:00" level...on" 4月 16 03:16:22 station.example.com systemd[1]: Started Docker Application Container Engine. 4月 16 03:16:22 station.example.com dockerd[31970]: time="2020-04-16T03:16:22.517677679+09:00" level...ck" Hint: Some lines were ellipsized, use -l to show in full.
起動できたようだ。
正しくインストールできたかを確認するために hello-world
イメージを実行する
# docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 1b930d010525: Pull complete Digest: sha256:026be68f01e5de09c8f591f382f7c4b2e3efefdca6acfab8f21f6b489a9cc70c 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/
成功したようだ。中身の説明にある通り、
- Docker client が Docker daemon に接続して
- hello-worldイメージが無いので Docker daemon が Docker Hub から引っ張ってくる。
- そのイメージから Docker daemon が新しいコンテナを作成。そのコンテナがこのメッセージを生成している。
- Docker daemon がこの生成メッセージを Docker client にストリーミングして、ターミナルに表示される。
という動きなのね。
これでインストールができた。
hello-worldのコンテナはこのメッセージを出力するだけで終了してしまうみたい。
docker ps
や docker images
コマンドで確認する。
# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ※なにも表示されない
オプションをつけないと現在起動しているコンテナだけを表示するので、何も見えない。
-a オプションをつけてすべてのコンテナを表示 # docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1cfca1d06453 hello-world "/hello" 10 minutes ago Exited (0) 10 minutes ago wizardly_elion
--no-trunc オプションをつけて、情報を省略しないで全部表示 # docker ps -a --no-trunc CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1cfca1d06453d3ab7aec4003e2a8f401d05bacf36b5e228703a5f10f494a2ea9 hello-world "/hello" 13 minutes ago Exited (0) 13 minutes ago wizardly_elion
IDがフル表示になっている。
# docker images REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest fce289e99eb9 15 months ago 1.84kB
余談
docker.service が止まっているとどうなるのか
systemctl stop docker
で止めた後どうなるのかやってみる。
# systemctl stop docker # docker ps -a --no-trunc Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
やっぱりクライアントの指示を受ける daemon が動いてないのでこうなるのね。