安装软件包
sudo apt install apt-transport-https ca-certificates software-properties-common
将 Docker 的 APT 源添加到系统中
echo "deb https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list
更新本地的 APT 包索引
sudo apt update
用于添加 GPG 公钥
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys (上一个命令的报错里面有密钥)
更新本地的 APT 包索引
sudo apt update
安装 Docker
sudo apt install docker-ce
查看docker版本
docker version
指定docker仓库
mkdir -p /etc/docker tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://mhlf8a7k.mirror.aliyuncs.com"] } EOF
systemctl daemon-reload
systemctl restart docker
拉个镜像验证docker
docker container run hello-world