使用 docker 命令检查是否已经安装了 docker
apt-get purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras -y
rm -rf /var/lib/docker rm -rf /var/lib/containerd
sudo apt install curl -y
sudo mkdir -m 0755 -p /etc/apt/keyrings
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor --yes -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin -y
如果按照过程中出现这样的错误
输入如下命令:
systemctl daemon-reload systemctl start docker
使用 hello-world
镜像测试
1. 创建阿里云账号,获取镜像加速器地址 点这里
2. 配置国内镜像源
sudo vim /etc/docker/daemon.json
{ "registry-mirrors": ["https://xznebf3p.mirror.aliyuncs.com", // 注释 此处为阿里云镜像地址,需注册阿里云账号获得 "https://registry.docker-cn.com", "https://docker.mirrors.ustc.edu.cn", "https://hub-mirror.c.163.com"] }
sudo systemctl daemon-reload // 重新加载配置 sudo systemctl restart docker // 重启 docker 服务
输入 docker run hello-world,若出现如下信息,则说明测试成功;
上一篇:浏览器渲染流程