快速安装 Docker

一键安装脚本

官方安装脚本

Docker 官方提供的安装脚本,但在国内可能无法直接访问:

curl -fsSL https://get.docker.com | bash -s docker

阿里云镜像安装

使用阿里云镜像源安装,适合国内网络环境:

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

系统特定安装方法

如果一键安装脚本无法满足需求,请根据您的操作系统选择对应的安装方法:

1. 更新包管理工具

sudo apt-get update

2. 添加阿里云源

由于网络原因,建议添加国内镜像源以加快安装速度:

sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
sudo curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/debian/gpg | sudo apt-key add -
sudo add-apt-repository -y "deb [arch=$(dpkg --print-architecture)] https://mirrors.aliyun.com/docker-ce/linux/debian $(lsb_release -cs) stable"
sudo apt-get update

3. 安装 Docker

sudo apt-get -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

4. 启动并设置自动启动

sudo systemctl start docker
sudo systemctl enable docker