Install Docker
Linux Install Docker Engine (Recommended)
Linux only requires installing Docker Engine; do not install Docker Desktop, as that is specifically designed for Mac and Windows.
Linux runs Docker with very low performance overhead, while the performance loss is relatively greater when running Docker on Windows and macOS.
https://docs.docker.com/engine/install/
https://mirrors.bfsu.edu.cn/help/docker-ce/
Ubuntu(APT)
The following content has been adapted from the official documentation.
If you have installed Docker before, delete it first:
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
First, install the dependencies and GPG:
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.asc
# 如果上面这行报错就弄下面这行
sudo chmod a+r /etc/apt/keyrings/docker.gpg
Trust Docker's GPG public key and add the repository:
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.bfsu.edu.cn/docker-ce/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Finally, install.
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Fedora(DNF5)
The following content has been adapted from the official documentation. (The official tutorial is still for DNF4 and is too outdated; please refer to the tutorial below.)
If you have installed Docker before, please remove it first.
sudo dnf remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
Install dependencies, download the repo file, and replace the software repository address with the mirror site:
sudo dnf -y install dnf-plugins-core
sudo dnf config-manager addrepo --from-repofile=https://download.docker.com/linux/fedora/docker-ce.repo
sudo sed -i 's+https://download.docker.com+https://mirrors.bfsu.edu.cn/docker-ce+' /etc/yum.repos.d/docker-ce.repo
Final installation:
sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Set up the environment
Check Docker service status:
On Linux, you can check the status of the Docker service with the following command:
systemctl status docker
Start the Docker service:
If the service is not running, you can use the following command to start the Docker service:
sudo systemctl start docker
Setting Docker to Start on Boot:
If you want Docker to start automatically every time your system boots, you can enable it to launch on startup:
sudo systemctl enable docker
Add the user to the docker group:
Use the following command to add the current user to the docker group:
sudo usermod -aG docker $USER
Log out and log back in:
After executing the above command, you need to log out of the current session and log back in, or run the following command to apply the changes:
newgrp docker
Restart the Docker service (if needed):
Make sure the Docker service is running. You can use the following command:
sudo systemctl start docker
Check Docker service status after restarting the computer:
First, restart your computer. Then you can check the status of the Docker service using the following command to see if it's running properly:
sudo reboot
systemctl status docker

Install Docker Desktop (Win, Mac)
(Docker Desktop on Windows and macOS uses a virtual machine, which comes with a performance penalty. It works on both systems, but you need to accept this performance loss. On Windows, the performance penalty is nearly identical to that of WSL2, because Docker Desktop for Windows is based on WSL2.)
(Docker Desktop on Linux is merely a GUI management tool for Docker Engine. It still uses Docker Engine by default to start containers, so there is almost no performance loss. Those who dislike using the command line may consider using it.)
Official download and installation: https://www.docker.com/
Windows Docker GPU Passthrough and USB Passthrough
To pass through an Nvidia GPU on Windows, you first need to enable WSL2 support in Docker Desktop settings and select a WSL2 distribution, such as Ubuntu 22.04. Next, you need to install the NVIDIA Container Toolkit inside the WSL2 Ubuntu 22.04 environment. The tutorial is provided below.
To enable USB passthrough on Docker for Windows, you first need to pass the USB device through to WSL2, then add the device to Docker using the docker run command. (If all WSL2 devices are already mounted to Docker, you only need to pass the USB through to WSL2.)


