CentOS Stream 9にdockerをインストールする

環境
CentOS Stream release 9

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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo dnf update
# sudo dnf update
# sudo dnf update

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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
#sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
#sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo

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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# dnf repolist
repo id repo の名前
anydesk AnyDesk CentOS - stable
appstream CentOS Stream 9 - AppStream
baseos CentOS Stream 9 - BaseOS
crb CentOS Stream 9 - CRB
docker-ce-stable Docker CE Stable - x86_64
epel Extra Packages for Enterprise Linux 9 - x86_64
epel-next Extra Packages for Enterprise Linux 9 - Next - x86_64
extras-common CentOS Stream 9 - Extras packages
mongodb-org-6.0 MongoDB Repository
mysql-connectors-community MySQL Connectors Community
mysql-tools-community MySQL Tools Community
mysql80-community MySQL 8.0 Community Server
nodesource Node.js Packages for Enterprise Linux 9 - x86_64
remi Remi's RPM repository for Enterprise Linux 9 - x86_64
remi-modular Remi's Modular repository for Enterprise Linux 9 - x86_64
remi-safe Safe Remi's RPM repository for Enterprise Linux 9 - x86_64
yarn Yarn Repository
# dnf repolist repo id repo の名前 anydesk AnyDesk CentOS - stable appstream CentOS Stream 9 - AppStream baseos CentOS Stream 9 - BaseOS crb CentOS Stream 9 - CRB docker-ce-stable Docker CE Stable - x86_64 epel Extra Packages for Enterprise Linux 9 - x86_64 epel-next Extra Packages for Enterprise Linux 9 - Next - x86_64 extras-common CentOS Stream 9 - Extras packages mongodb-org-6.0 MongoDB Repository mysql-connectors-community MySQL Connectors Community mysql-tools-community MySQL Tools Community mysql80-community MySQL 8.0 Community Server nodesource Node.js Packages for Enterprise Linux 9 - x86_64 remi Remi's RPM repository for Enterprise Linux 9 - x86_64 remi-modular Remi's Modular repository for Enterprise Linux 9 - x86_64 remi-safe Safe Remi's RPM repository for Enterprise Linux 9 - x86_64 yarn Yarn Repository
#  dnf repolist
repo id                              repo の名前
anydesk                              AnyDesk CentOS - stable
appstream                            CentOS Stream 9 - AppStream
baseos                               CentOS Stream 9 - BaseOS
crb                                  CentOS Stream 9 - CRB
docker-ce-stable                     Docker CE Stable - x86_64
epel                                 Extra Packages for Enterprise Linux 9 - x86_64
epel-next                            Extra Packages for Enterprise Linux 9 - Next - x86_64
extras-common                        CentOS Stream 9 - Extras packages
mongodb-org-6.0                      MongoDB Repository
mysql-connectors-community           MySQL Connectors Community
mysql-tools-community                MySQL Tools Community
mysql80-community                    MySQL 8.0 Community Server
nodesource                           Node.js Packages for Enterprise Linux 9 - x86_64
remi                                 Remi's RPM repository for Enterprise Linux 9 - x86_64
remi-modular                         Remi's Modular repository for Enterprise Linux 9 - x86_64
remi-safe                            Safe Remi's RPM repository for Enterprise Linux 9 - x86_64
yarn                                 Yarn Repository

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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo dnf -y install device-mapper-persistent-data lvm2
# sudo dnf -y install device-mapper-persistent-data lvm2
# sudo dnf -y install device-mapper-persistent-data lvm2

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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo dnf install docker-ce --allowerasing
# sudo dnf install docker-ce --allowerasing
# sudo dnf install docker-ce --allowerasing

6.dockerバージョンを確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# docker -v
Docker version 20.10.18, build b40c2f6
# docker -v Docker version 20.10.18, build b40c2f6
# docker -v
Docker version 20.10.18, build b40c2f6

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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# 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
# 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
# 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をユーザーで実行します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo usermod -aG docker ${USER}
# newgrp docker
# id $USER
uid=0(root) gid=0(root) groups=0(root),972(docker)
# sudo usermod -aG docker ${USER} # newgrp docker # id $USER uid=0(root) gid=0(root) groups=0(root),972(docker)
# sudo usermod -aG docker ${USER}
# newgrp docker
# id $USER
uid=0(root) gid=0(root) groups=0(root),972(docker)

9.動作確認

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# docker run hello-world
# docker run hello-world
# docker run hello-world

 

CentOS Stream 9

Posted by arkgame