Rocky Linux 9 にdockerをインストールする

環境
OSバージョンを確認します
# cat /etc/redhat-release
Rocky Linux release 9.0 (Blue Onyx)

操作方法
1.システムパッケージを更新します

# sudo dnf update

2.docker リポジトリを追加します

# sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
repo の追加: https://download.docker.com/linux/centos/docker-ce.repo

3.追加したリポジトリを確認します

# dnf repolist

4.必要なパッケージをインストールします

# sudo dnf -y install device-mapper-persistent-data lvm2

5.dockerをインストールします

# sudo dnf install docker-ce docker-ce-cli containerd.io docker-compose-plugin --allowerasing

6.インストールが完了したら、バージョンを確認します。

# docker -v
Docker version 20.10.20, build 9fdeb9c

7.docker起動と自動起動を設定します

# sudo systemctl enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
# sudo systemctl start docker

8.dockerをユーザーで実行します
dockerをユーザーで実行できるようにdockerグループに追加します。

# sudo usermod -aG docker ${USER}
# newgrp docker
# id $USER
uid=0(root) gid=0(root) groups=0(root),972(docker)

9.動作確認
# docker run hello-world

実行結果

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:18a657d0cc1c7d0678a3fbea8b7eb4918bba25968d3e1b0adebfa71caddbc346
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/

 

Rocky Linux 9

Posted by arkgame