Docker 安装
确保系统安装依赖
sudo apt-get update sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
添加 Docker 官方 GPG 密钥
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
添加 Docker APT 源
echo "deb [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
sudo apt-get update sudo apt-get install -y docker-ce docker-ce-cli containerd.io
启动 Docker 服务并设置开机自启
sudo systemctl start docker sudo systemctl enable docker
验证 Docker 安装
docker --version
Docker 移除
停止 Docker 服务
sudo systemctl stop docker
删除 Docker 软件包
sudo apt-get purge docker-ce docker-ce-cli containerd.io
删除 Docker 相关的数据和配置文件(可选)
sudo rm -rf /var/lib/docker sudo rm -rf /etc/docker