返回

国内源安装docker

   
摘要GPT
摘要小助理暂时失联跑路啦……😜

基于ubuntu22.04

更新索引包

sudo apt update

安装设置仓库必须的工具

sudo apt update && sudo apt install -y ca-certificates curl gnupg lsb-release

安装HTTPS支持包

sudo apt -y install apt-transport-https ca-certificates curl software-properties-common

添加软件源的GPG密钥

sudo curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/aliyun-docker.gpg

添加Docker软件源

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/trusted.gpg.d/aliyun-docker.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

安装

sudo apt update
sudo apt install -y docker-ce

启动后台服务

sudo service docker start
sudo systemctl restart docker
sudo systemctl start docker

查看 Docker 服务状态

sudo systemctl status docker

开启自启动

sudo systemctl enable docker

将当前用户添加到 docker 用户组

sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker

配置镜像加速

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://oyac73nr.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

查看加速配置是否生效

sudo docker info

正确的效果

以上省略 
 Registry Mirrors:
  https://oyac73nr.mirror.aliyuncs.com/
 Live Restore Enabled: false

创建软链接

sudo ln -s /usr/libexec/docker/cli-plugins/docker-compose /usr/bin/docker-compose

注意: /usr/libexec/docker/cli-plugins/docker-compose 通过 sudo docker info 查找

查看docker-compose版本

sudo docker-compose -v

卸载docker

即使报错,也能干净

sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get purge docker-ce docker-ce-cli containerd.io
sudo rm -rf /var/lib/docker  
sudo rm -rf /var/lib/containerd
sudo apt-get remove -y docker* containerd.io podman* runc && apt-get autoremove

其他问题

cd /etc/apt/sources.list.d/

删除与Docker 相关的文件,

sudo apt clean
sudo apt update
知识共享许可证 CC BY-NC-SA 4.0
最后更新于 2024-06-16 00:45
使用 Hugo 构建
主题 hugo-magic小洋葱 魔改 由 Jimmy 设计
Written by Human, Not by AI