Ubuntu安装Docker-CE

默认分类 · 2023-08-22

1.安装依赖

apt-get update
apt-get install ca-certificates curl gnupg

2.安装gpg密钥,配置tuna Docker-CE源

install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu/gpg | gpg --dearmor \
-o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  tee /etc/apt/sources.list.d/docker.list > /dev/null

3.安装Docker-CE

apt update
apt install docker-ce

apt安装完会配置自启,不用手动操作

4.配置上交镜像源

mkdir /etc/docker
cat > /etc/docker/daemon.json << EOF
{
  "registry-mirrors": ["https://docker.mirrors.sjtug.sjtu.edu.cn"]
}
EOF

重启docker

systemctl daemon-reload
systemctl restart docker.service
Theme Jasmine by Kent Liao