Debian系统上安装Docker详细步骤

Linux · 2024-04-04
Debian系统上安装Docker详细步骤

在Debian系统上安装Docker,可以按照以下步骤操作:

1.更新软件包索引:

sudo apt-get update

2.Install using the apt repository
安装必要的软件包以允许apt通过HTTPS使用仓库:

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/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

Add the repository to Apt sources:

echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

3.安装稳定版本 install the latest version
apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

4.验证安装结果 Verify that the installation is successful by running the hello-world image:
docker run hello-world

如果你想让非root用户也能运行Docker命令,可以将该用户添加到docker组:

sudo usermod -aG docker $USER

注销并重新登录,以确保用户组改变生效。

debian linux docker