インストール方法に行き着いた流れ。
調査するの苦手だから流れを書いておく。
検索ワード: docker install
→ Install Docker Engine
なんやかんやでこちら
でServerの「CentOS」をクリックすると手順発見。
※もちろん、CentOS以外もあるよ。
インストール手順
上の手順だとCentOS Stream8でもyumを使っている。dnfであえて手順を変えてやってみた。
Set up the repository
yum-config-managerは以下のコマンドに置き換え可能。どうやらdnfは、yum + yum-config-managerの機能があるようだ。
> sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
Install Docker Engine
dockerインストール時の3要素以外に、composeもパッケージとしてインストールできるみたい。
curl使ってインストールする方法以外知らなかった…。
> sudo dnf install docker-ce docker-ce-cli containerd.io docker-compose-plugin
Dockerのバージョン確認
ちなみに、一番下のエラー(?)メッセージについては、要はDockerプロセス(デーモン)が起動していないことが原因のため、「Dockerプロセスのステータス確認」で対応している。
> docker version
Client: Docker Engine - Community
Version: 20.10.18
API version: 1.41
Go version: go1.18.6
Git commit: b40c2f6
Built: Thu Sep 8 23:11:56 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Docker Composeのバージョン確認
docker-composeコマンドかと思いきや、以下のコマンドでcomposeが利用できるらしい。
> docker compose version
Docker Compose version v2.10.2
Dockerプロセスのステータス確認
Dockerプロセスが起動しているか確認し、未起動のためDockerプロセスを起動し確認している。
> sudo systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Docs: https://docs.docker.com
>sudo systemctl start docker
> sudo 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 Sun 2022-10-09 01:50:18 JST; 18s ago
Docs: https://docs.docker.com
Main PID: 151552 (dockerd)
Tasks: 8
Memory: 101.0M
CGroup: /system.slice/docker.service
└─151552 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
動作確認
> sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:62af9efd515a25f84961b70f973a798d2eca956b1b2b026d0a4a63a3b0b6a3f2
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/
ちなみに
気になったのが、–sshオプションだ。ビルドに指定するらしい。鍵かソケットを指定するらしい。コンテナに直接sshするんだろうが、ビルド時にそれ指定するのかい?それにホストとコンテナのどっちだろう。