Debian 安装 Docker
1. 安装依赖
apt update && apt install ca-certificates curl -y
2. 添加 Docker 官方 GPG 密钥
install -m 0755 -d /etc/apt/keyrings && curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc && chmod a+r /etc/apt/keyrings/docker.asc
3. 添加存储库到 Apt 源:
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" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
4. 安装 Docker 软件包
apt update && apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
5. 运行 hello-world 镜像,验证安装是否成功:
docker run hello-world
额外的操作
防止日志打满硬盘:Docker 限制日志文件大小
配置镜像加速:Docker 配置镜像加速器
自动更新 Docker 镜像与容器:给 Docker 加点特技