Try   HackMD

我們的server設備為

OS版本: RH8.4 /x86_64
GPU: CUDA11.7

到官網選擇適合的系統版本
[ref] Install Docker Engine

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

先選擇 "RHEL"看看
[ref] Install Docker Engine on RHEL

Prerequisites

OS requirements

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

發現版本為x86_64, 不符合s390x 條件

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

> 或許可改走 "CentOS" 的方法
[ref] Install Docker Engine on CentOS

Q:Unable to install docker on rhel 8 linux

(opt) Uninstall old versions

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

  1. Install Docker Engine, changing the path below to the path where you downloaded the Docker package.
sudo yum install /path/to/package.rpm
  1. 啟動 Docker
sudo systemctl start docker
  1. 通過運行 image 確認 Docker Engine 是否安裝成功
sudo docker run hello-world

此命令下載測試映像並在容器中運行它。當容器運行時,它會打印一條確認消息並退出。

Docker Engine 的 Linux 安裝後步驟

[ref] Linux post-installation steps for Docker Engine
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.
sudo groupadd docker
  1. Add your user to the docker group.
sudo usermod -aG docker $USER
  1. 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:

newgrp docker

驗證是否可在沒有 sudo 下運行 docker

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:

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:

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

在 Debian 和 Ubuntu 上,Docker 服務默認在啟動時啟動。
要使用 systemd 在其他 Linux 發行版上自動啟動 Docker 和 Containerd,請運行以下指令:

sudo systemctl enable docker.service
sudo systemctl enable containerd.service

若要改回停止此行為,請使用 disable 指令

sudo systemctl disable docker.service
sudo systemctl disable containerd.service

確認支援使用 gpu 運算

讓 docker container 支援使用gpu運算

docker-ce 從19.03版之後,Docker 引擎已經原生支援 NVIDIA GPU 運算,不再需要額外安裝 NVIDIA Docker 支援(NVIDIA Docker runtime)。

先前版本可參考: [安裝紀錄] 安裝 Docker-CE 與使用 Nvidia GPU
所以我們可以免安裝直接確認是否支援 GPU

啟動一個 container 來測試是否可偵測到

$ sudo docker run --gpus 1 -i -t nvidia/cuda:10.0-base nvidia-smi

若正常會會顯示GPU資訊

其他補充

END