:::info [TOC] ::: 我們的server設備為 ``` OS版本: RH8.4 /x86_64 GPU: CUDA11.7 ``` 到官網選擇適合的系統版本 [[ref] Install Docker Engine](https://docs.docker.com/engine/install/) ![](https://hackmd.io/_uploads/ByW90i3q3.png =500x) 先選擇 "RHEL"看看 [[ref] Install Docker Engine on RHEL](https://docs.docker.com/engine/install/rhel/) ## Prerequisites ### OS requirements ![](https://hackmd.io/_uploads/ByYSKi25h.png =500x) ![](https://hackmd.io/_uploads/BJOmRnsc2.png =500x) 發現版本為`x86_64`, 不符合`s390x` 條件 :cry: --> 或許可改走 "CentOS" 的方法 [[ref] Install Docker Engine on CentOS](https://docs.docker.com/engine/install/centos/) [Q:Unable to install docker on rhel 8 linux](https://access.redhat.com/discussions/6249651) ### (opt) Uninstall old versions ```shell sudo yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-engine ``` ## Install from a package 下載 RPM package 並手動安裝 1. 到 `https://download.docker.com/linux/centos/` 選擇對應版本中的 `x86_64/stable/Packages/` 安裝檔案 `.rpm` https://download.docker.com/linux/centos/8/x86_64/stable/Packages/docker-ce-24.0.4-1.el8.x86_64.rpm 2. Install Docker Engine, changing the path below to the path where you downloaded the Docker package. ```shell sudo yum install /path/to/package.rpm ``` 3. 啟動 Docker ```shell sudo systemctl start docker ``` 4. 通過運行 image 確認 Docker Engine 是否安裝成功 ```shell sudo docker run hello-world ``` 此命令下載測試映像並在容器中運行它。當容器運行時,它會打印一條確認消息並退出。 ## Docker Engine 的 Linux 安裝後步驟 [[ref] Linux post-installation steps for Docker Engine](https://docs.docker.com/engine/install/linux-postinstall/) Continue to Linux postinstall to allow non-privileged users to run Docker commands and for other optional configuration steps. ### 以非 root 使用者管理 Docker To create the `docker` group and add your user: 1. Create the `docker` group. ```shell sudo groupadd docker ``` 2. Add your user to the docker group. ```shell sudo usermod -aG docker $USER ``` 3. Log out and log back in so that your group membership is re-evaluated. You can also run the following command to activate the changes to groups: ```shell newgrp docker ``` 驗證是否可在沒有 sudo 下運行 docker ```shell docker run hello-world ``` 此指令下載測試映像並在容器中運行它。當容器運行時,它會打印一條確認消息並退出。 ### (opt) 可能會遇到的權限錯誤 If you initially ran Docker CLI commands using `sudo` before adding your user to the `docker` group, you may see the following error: ```shell WARNING: Error loading config file: /home/user/.docker/config.json - stat /home/user/.docker/config.json: permission denied ``` This error indicates that the permission settings for the ``~/.docker/`` directory are incorrect, due to having used the `sudo` command earlier. To fix this problem, either remove the ``~/.docker/`` directory (it’s recreated automatically, but any custom settings are lost), or change its ownership and permissions using the following commands: ```shell sudo chown "$USER":"$USER" /home/"$USER"/.docker -R sudo chmod g+rwx "$HOME/.docker" -R ``` ### (opt) 使用 systemd 設定 Docker 在開機時自動啟動 [Configure Docker to start on boot with systemd](https://docs.docker.com/engine/install/linux-postinstall/#configure-docker-to-start-on-boot-with-systemd) 在 Debian 和 Ubuntu 上,Docker 服務默認在啟動時啟動。 要使用 systemd 在其他 Linux 發行版上自動啟動 Docker 和 Containerd,請運行以下指令: ```shell sudo systemctl enable docker.service sudo systemctl enable containerd.service ``` 若要改回停止此行為,請使用 disable 指令 ```shell sudo systemctl disable docker.service sudo systemctl disable containerd.service ``` ### 確認支援使用 gpu 運算 讓 docker container 支援使用gpu運算 :::success docker-ce 從19.03版之後,Docker 引擎已經原生支援 NVIDIA GPU 運算,不再需要額外安裝 NVIDIA Docker 支援(NVIDIA Docker runtime)。 ::: 先前版本可參考: [[安裝紀錄] 安裝 Docker-CE 與使用 Nvidia GPU](https://hackmd.io/@RinKu1998/rkd3vTaoP) 所以我們可以免安裝直接確認是否支援 GPU 啟動一個 container 來測試是否可偵測到 ``` $ sudo docker run --gpus 1 -i -t nvidia/cuda:10.0-base nvidia-smi ``` 若正常會會顯示GPU資訊 ## 其他補充 - 另一條路可試- 離線版centos8安裝docker筆記 https://cloud.tencent.com/developer/article/1930492 -- END --