一、卸载旧版本
sudo apt-get remove docker docker-engine docker.io containerd runc
二、使用存储库安装
1、安装依赖工具
sudo apt-get update
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
2、添加docker官方GPG key
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
3、配置软件包源
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
4、安装Docker Engine
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
三、配置阿里云容器镜像
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors":["https://xxxxxxxx.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
使用您的阿里云容器镜像加速器地址替换
四、非root用户身份管理Docker
1、创建用户组
sudo groupadd docker
2、添加当前用户到docker用户组
sudo usermod -aG docker $USER
3、注销登录或者重启使更改生效;或执行下面的命令在当前会话立即生效
newgrp docker
阿里云容器镜像服务: https://cr.console.aliyun.com/cn-hangzhou/instances/mirror
docker官方文档: https://docs.docker.com/engine/install/ubuntu/
网友评论