AlmaLinux dockerをインストールするまでの手順

AlmaLinuxにdockerとdocker composeをインストールするまでの手順です。
環境
- OS AlmaLinux 8.3
リポジトリ追加
まずはリポジトリを追加します。
1 |
sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo |
追加したリポジトリを確認します。
1 2 3 4 5 6 7 8 9 |
dnf repolist <出力結果> repo id repo の名前 appstream AlmaLinux 8 - AppStream baseos AlmaLinux 8 - BaseOS docker-ce-stable Docker CE Stable - x86_64 extras AlmaLinux 8 - Extras powertools AlmaLinux 8 - PowerTools |
dockerインストール
以下のコマンドを実行してインストールを行います。
1 |
sudo dnf -y install docker-ce |
以下のエラーが出る場合は、
1 2 3 4 5 6 7 8 9 10 11 12 |
<出力結果> エラー: 問題: package docker-ce-3:19.03.3-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed - cannot install the best candidate for the job - package containerd.io-1.2.10-3.2.el7.x86_64 is excluded - package containerd.io-1.2.2-3.3.el7.x86_64 is excluded - package containerd.io-1.2.2-3.el7.x86_64 is excluded - package containerd.io-1.2.4-3.1.el7.x86_64 is excluded - package containerd.io-1.2.5-3.1.el7.x86_64 is excluded - package containerd.io-1.2.6-3.3.el7.x86_64 is excluded (try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages) |
containerd.ioを入手して、インストールします。
1 2 3 4 |
wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.2-3.3.el7.x86_64.rpm sudo dnf remove containerd.io sudo dnf install containerd.io-1.2.2-3.3.el7.x86_64.rpm sudo dnf install -y docker-ce docker-ce-cli --nobest |
インストールが完了したら、バージョンを確認してみます。
1 2 3 4 |
docker --version <出力結果> Docker version 20.10.5, build 55c4c88 |
起動と自動起動を設定します。
1 2 |
sudo systemctl enable docker sudo systemctl start docker |
dockerをユーザーで実行
dockerをユーザーで実行できるようにdockerグループに追加しておきます。
1 |
sudo usermod -aG docker ${USER} |
再起動して、一度、接続を抜けてもう一度接続すれば、ユーザーで実行できます。
※別の接続を行っても同様で「su – ${USER}」を実行しても同じです。
1 |
sudo systemctl restart docker |
追加していない場合は、以下のエラーが発生します。
1 2 3 4 5 6 |
docker info <出力結果> Server: ERROR: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.24/info: dial unix /var/run/docker.sock: connect: permission denied errors pretty printing info |
hello worldができればインストールは完了です。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
docker run hello-world <出力結果> Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world b8dfde127a29: Pull complete Digest: sha256:308866a43596e83578c7dfa15e27a73011bdd402185a84c5cd7f32a88b501a24 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/ |
hello worldできれば削除しておきます。
1 2 3 4 5 6 7 8 9 10 11 12 |
docker rm $(docker ps -q -a) <出力結果> f422a43ab5a5 docker rmi $(docker images -q) <出力結果> Untagged: hello-world:latest Untagged: hello-world@sha256:308866a43596e83578c7dfa15e27a73011bdd402185a84c5cd7f32a88b501a24 Deleted: sha256:d1165f2212346b2bab48cb01c1e39ee8ad1be46b87873d9ca7a4e434980a7726 Deleted: sha256:f22b99068db93900abe17f7f5e09ec775c2826ecfe9db961fea68293744144bd |
docker composeインストール
docker composeもインストールしておきます。
こちらのサイトより最新版を確認します。

最新版が1.29.0だったので、これをインストールします。
1 |
sudo wget -O /usr/local/bin/docker-compose https://github.com/docker/compose/releases/download/1.29.0/docker-compose-Linux-x86_64 |
権限も設定しておきます。
1 |
sudo chmod +x /usr/local/bin/docker-compose |
バージョンを確認すると、最新のバージョンである「1.29.0」がインストールされていることが確認できます。
1 2 3 4 5 6 7 |
docker-compose version <出力結果> docker-compose version 1.29.0, build 07737305 docker-py version: 5.0.0 CPython version: 3.7.10 OpenSSL version: OpenSSL 1.1.0l 10 Sep 2019 |
-
前の記事
dockerを使って「Graphite」を構築するまでの手順 2021.04.08
-
次の記事
gitlab テーマを変更する 2021.04.09
コメントを書く