# debian（测试版）安装docker

By [高同学Daniel](https://paragraph.com/@danielgao) · 2021-12-30

---

[https://docs.docker.com/engine/install/debian/#prerequisites](https://link.zhihu.com/?target=https%3A//docs.docker.com/engine/install/debian/%23prerequisites)

docker的安装有三种方式。第一种手动命令行安装和第三种通过脚本安装是一样的。

我使用了第三种方式，也就是通过脚本安装。

    $ curl -fsSL https://get.docker.com -o get-docker.sh
    $ sudo sh get-docker.sh
    

脚本会检测你的debian版本，根据版本信息拼接下载链接，然后自动创建docker的软件源文件：apt/sources.list.d/docker.list。

我用的是bookworm测试版，所以生成的源会是这样：`https://download.docker.com/linux/debian bookworm InRelease`  
但是docker的源还没有这个下载链接，所以需要修改一下下载源的信息，将bookworm修改成bullseye就可以了。修改后是这样：

`https://download.docker.com/linux/debian bullseye InRelease`

然后手动安装docker：

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

测试是否安装成功：

`$ sudo docker run hello-world`

查看可用的版本：

    $ apt-cache madison docker-ce
    

安装指定版本：

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

---

*Originally published on [高同学Daniel](https://paragraph.com/@danielgao/debian-docker)*
