debian docker 安装

docker官方文档:https://docs.docker.com/engine/install/debian/

参考官方文档,傻瓜式安装

服务器:debian11

这边采用apt安装docker源的方式

Step1:删除旧版本

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

images, containers, volumes, networks保存在/var/lib/docker/目录,apt remove并不会删除。

Step2:更新安装相关依赖

1
2
3
4
5
6
sudo apt-get update
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release

Step3:apt安装docker源

  • 添加docker官方GPG密钥

    1
    2
    mkdir -p /etc/apt/keyrings
    curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
  • apt添加docker源

    1
    2
    3
    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

Step4:docker engine安装

  1. 最新版

    1
    sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
  2. 历史版本

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    # List the available versions:
    apt-cache madison docker-ce | awk '{ print $3 }'

    5:18.09.1~3-0~debian-stretch
    5:18.09.0~3-0~debian-stretch
    18.06.1~ce~3-0~debian
    18.06.0~ce~3-0~debian

    VERSION_STRING=5:18.09.0~3-0~debian-stretch
    apt-get install docker-ce=$VERSION_STRING docker-ce-cli=$VERSION_STRING containerd.io docker-compose-plugin

Step5:更新

同Step4