腾讯云Debian系统安装Docker简明指南
结论: 在腾讯云Debian系统上安装Docker只需几个简单步骤,主要包括更新系统、安装依赖、添加Docker官方仓库并安装Docker引擎。
安装步骤
1. 系统准备
- 通过SSH登录腾讯云Debian服务器
- 更新系统软件包:
sudo apt update && sudo apt upgrade -y
2. 安装必要依赖
- 安装允许apt通过HTTPS使用仓库的软件包:
sudo apt install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common
3. 添加Docker官方GPG密钥
- 确保下载的软件包来自可信源:
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
4. 设置Docker稳定版仓库
- 添加Docker官方仓库到APT源:
echo "deb [arch=$(dpkg --print-architecture) 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
5. 安装Docker引擎
- 更新APT包索引并安装Docker:
sudo apt update sudo apt install -y docker-ce docker-ce-cli containerd.io
6. 验证安装
- 检查Docker版本确认安装成功:
docker --version
- 运行测试容器:
sudo docker run hello-world
配置优化(可选)
1. 非root用户权限
- 将当前用户加入docker组避免每次使用sudo:
sudo usermod -aG docker $USER
需要重新登录使更改生效
2. 设置开机自启
- 配置Docker服务随系统启动:
sudo systemctl enable docker
常见问题解决
-
网络问题:腾讯云服务器可能需要配置镜像提速
sudo mkdir -p /etc/docker sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://mirror.ccs.tencentyun.com"] } EOF sudo systemctl restart docker
-
Debian版本兼容性:确保Debian版本在Docker支持列表中
核心要点: 通过官方仓库安装Docker能确保获得最新稳定版本,腾讯云环境下配置镜像提速可显著提升拉取镜像速度。