跳至正文

Debian 安装 Docker CE

系统需求

  • Debian Bullseye 11 (stable)
  • Debian Buster 10 (oldstable)
  • Raspbian Bullseye 11 (stable)
  • Raspbian Buster 10 (oldstable)

卸载 Docker 旧版本

sudo apt-get remove docker docker-engine docker.io containerd runc

使用 repository 安装 Docker Engine

配置 repository

sudo apt-get update
sudo apt-get install \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

添加 Docker GPG key

sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

安装最新 Docker Engine

此命令将会安装最新的 Docker Engine, containerd 和 Docker Compose

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin

或者安装自选版本 Docker Engine

列出可用的安装版本

apt-cache madison docker-ce

安装自选版本的 Docker Engine, containerd 和 Docker Compose

sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io docker-compose-plugin

安装完成后启动 Docker Engine

sudo systemctl start docker

设置 Docker Engine 自启动

sudo systemctl enable docker

卸载 Docker Engine

卸载 Docker Engine, containerd 和 Docker Compose

sudo apt-get purge docker-ce docker-ce-cli containerd.io docker-compose-plugin

删除 Docker Engine 所有的残留(images, containers 和 volumes)

sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd

参考文章:Install Docker Engine on Debian | Docker Documentation


发表评论须遵守中华人民共和国相关法律法规。违规评论将会被删除。

Comments must subject to the relevant laws and regulations of the People’s Republic of China. Offending comments will be deleted.

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据