刚刚安装好的Debain需要修改一下源
- 编辑 /etc/apt/sources.list 文件
nano /etc/apt/sources.list
- 将文本内的源都注视掉,然后复制粘贴下面的源,亲测有效
deb https://mirrors.huaweicloud.com/debian/ bullseye main non-free contrib
deb https://mirrors.huaweicloud.com/debian/ bullseye-updates main non-free contrib
deb https://mirrors.huaweicloud.com/debian/ bullseye-backports main non-free contrib
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security/ bullseye-security main non-free contrib
deb https://security.debian.org/debian-security bullseye-security main non-free contrib
deb-src https://mirrors.huaweicloud.com/debian/ bullseye main non-free contrib
deb-src https://mirrors.huaweicloud.com/debian/ bullseye-updates main contrib
deb-src https://mirrors.huaweicloud.com/debian/ bullseye-backports main non-free contrib
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security/ bullseye-security main non-free contrib
deb-src https://security.debian.org/debian-security bullseye-security main non-free contrib
- 按下
ctrl+x
,输入Y
再按下回车
即可保存 - 更新源,输入命令:
apt update
- 安装必要的软件包:
sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release
- 添加Docker GPG密钥
添加Docker GPG密钥,以便您的系统信任Docker软件包:
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
- 添加Docker软件包源
将Docker软件包源添加到系统的APT源列表中:
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.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和其他必要的软件包:
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io
- 启动 Docker
使用以下命令启动 Docker:
sudo systemctl start docker
检查 Docker 是否正在运行:
sudo systemctl status docker
- 使用Docker
安装完成后,您可以使用“docker”命令在终端上使用Docker了。例如,运行以下命令以显示Docker版本信息:
docker version
或者,您可以运行以下命令以启动一个容器:
docker run hello-world
这将下载“hello-world”图像并在容器中运行它。如果一切都设置正确,将在终端上显示相应的输出。
希望这可以帮助您在Debian 11上安装Docker。
版权归原作者 selier0 所有, 如有侵权,请联系我们删除。