From: 011netservice@gmail.com Date: 2025-06-23 Subject: Install-docker-RedHat https://svc.011.idv.tw/CodeHelper/Docker/Install-docker-RedHat.txt 歡迎來信交流, 訂購軟體需求. #### 安裝 docker, 容器軟體 1. 移除舊版本(如果有) $ sudo dnf remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-engine [sudo] password for administrator: Updating Subscription Management repositories. No match for argument: docker No match for argument: docker-client No match for argument: docker-client-latest No match for argument: docker-common No match for argument: docker-latest No match for argument: docker-latest-logrotate No match for argument: docker-logrotate No match for argument: docker-engine No packages marked for removal. Dependencies resolved. Nothing to do. Complete! 2. 安裝必要套件 $ sudo dnf -y install dnf-plugins-core Updating Subscription Management repositories. Last metadata expiration check: 2:24:54 ago on Mon 16 Jun 2025 08:26:28 PM EDT. Package dnf-plugins-core-4.3.0-20.el9.noarch is already installed. Dependencies resolved. Nothing to do. Complete! 3. 新增 Docker 官方儲存庫 $ sudo dnf config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo Updating Subscription Management repositories. Adding repo from: https://download.docker.com/linux/centos/docker-ce.repo 雖然網址是 `centos`,但這個 repo 同樣適用於 RHEL。 4. 安裝 Docker Engine $ sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin Updating Subscription Management repositories. Docker CE Stable - x86_64 284 kB/s | 73 kB 00:00 Dependencies resolved. ============================================================================================================================================================ Package Architecture Version Repository Size ============================================================================================================================================================ Installing: containerd.io x86_64 1.7.27-3.1.el9 docker-ce-stable 44 M docker-buildx-plugin x86_64 0.24.0-1.el9 docker-ce-stable 16 M docker-ce x86_64 3:28.2.2-1.el9 docker-ce-stable 20 M docker-ce-cli x86_64 1:28.2.2-1.el9 docker-ce-stable 8.5 M docker-compose-plugin x86_64 2.36.2-1.el9 docker-ce-stable 15 M Installing weak dependencies: docker-ce-rootless-extras x86_64 28.2.2-1.el9 docker-ce-stable 3.4 M Transaction Summary ============================================================================================================================================================ Install 6 Packages Total download size: 107 M Installed size: 430 M Is this ok [y/N]: y Downloading Packages: (1/6): docker-buildx-plugin-0.24.0-1.el9.x86_64.rpm 3.2 MB/s | 16 MB 00:05 (2/6): docker-ce-28.2.2-1.el9.x86_64.rpm 3.5 MB/s | 20 MB 00:05 (3/6): docker-ce-rootless-extras-28.2.2-1.el9.x86_64.rpm 823 kB/s | 3.4 MB 00:04 (4/6): docker-ce-cli-28.2.2-1.el9.x86_64.rpm 1.6 MB/s | 8.5 MB 00:05 (5/6): docker-compose-plugin-2.36.2-1.el9.x86_64.rpm 3.1 MB/s | 15 MB 00:04 (6/6): containerd.io-1.7.27-3.1.el9.x86_64.rpm 2.3 MB/s | 44 MB 00:19 ------------------------------------------------------------------------------------------------------------------------------------------------------------ Total 5.6 MB/s | 107 MB 00:19 Docker CE Stable - x86_64 17 kB/s | 1.6 kB 00:00 Importing GPG key 0x621E9F35: Userid : "Docker Release (CE rpm) " Fingerprint: 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35 From : https://download.docker.com/linux/centos/gpg Is this ok [y/N]: y Key imported successfully Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : docker-buildx-plugin-0.24.0-1.el9.x86_64 1/6 Running scriptlet: docker-buildx-plugin-0.24.0-1.el9.x86_64 1/6 Installing : docker-compose-plugin-2.36.2-1.el9.x86_64 2/6 Running scriptlet: docker-compose-plugin-2.36.2-1.el9.x86_64 2/6 Installing : docker-ce-cli-1:28.2.2-1.el9.x86_64 3/6 Running scriptlet: docker-ce-cli-1:28.2.2-1.el9.x86_64 3/6 Installing : containerd.io-1.7.27-3.1.el9.x86_64 4/6 Running scriptlet: containerd.io-1.7.27-3.1.el9.x86_64 4/6 Installing : docker-ce-rootless-extras-28.2.2-1.el9.x86_64 5/6 Running scriptlet: docker-ce-rootless-extras-28.2.2-1.el9.x86_64 5/6 Installing : docker-ce-3:28.2.2-1.el9.x86_64 6/6 Running scriptlet: docker-ce-3:28.2.2-1.el9.x86_64 6/6 Verifying : containerd.io-1.7.27-3.1.el9.x86_64 1/6 Verifying : docker-buildx-plugin-0.24.0-1.el9.x86_64 2/6 Verifying : docker-ce-3:28.2.2-1.el9.x86_64 3/6 Verifying : docker-ce-cli-1:28.2.2-1.el9.x86_64 4/6 Verifying : docker-ce-rootless-extras-28.2.2-1.el9.x86_64 5/6 Verifying : docker-compose-plugin-2.36.2-1.el9.x86_64 6/6 Installed products updated. Installed: containerd.io-1.7.27-3.1.el9.x86_64 docker-buildx-plugin-0.24.0-1.el9.x86_64 docker-ce-3:28.2.2-1.el9.x86_64 docker-ce-cli-1:28.2.2-1.el9.x86_64 docker-ce-rootless-extras-28.2.2-1.el9.x86_64 docker-compose-plugin-2.36.2-1.el9.x86_64 Complete! 5. 啟動並設定 Docker 開機自動啟動 $ 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. 6. 驗證安裝 $ docker --version Docker version 28.2.2, build e6534b4 $ sudo docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world e6590344b1a5: Pull complete Digest: sha256:940c619fbd418f9b2b1b63e25d8861f9cc1b46e3fc8b018ccfe8b78f19b8cc4f 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/ 7. 讓非 root 使用者可以執行 Docker $ sudo usermod -aG docker $USER 執行完這個指令後,請 登出再登入,讓群組變更生效。