【个人亲试最新】WSL2中的Ubuntu 22.04安装Docker

文章目录


😊点此到文末惊喜↩︎


Wsl2中的Ubuntu22.04安装Docker

友情提示:确定为wsl2+ubuntu22.04,若按照以下步骤失败,请完全卸载后重装docker,并检查wsl版本

  1. 安装依赖包
c 复制代码
sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release
  1. 添加阿里云镜像源和密钥
c 复制代码
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
  1. 添加阿里云镜像源
c 复制代码
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  1. 从软件源中更新安装工具包
c 复制代码
sudo apt update
  1. 安装Docker套件
c 复制代码
sudo apt install docker-ce docker-ce-cli containerd.io
  1. 配置Docker镜像源
    • 配置阿里云需要注册,并在 阿里云个人镜像源网址 中获取个人镜像源
    • 其他镜像加速地址如8. 其他镜像源加速地址所示
c 复制代码
1.创建Docker文件夹
sudo mkdir -p /etc/docker
2.写入个人镜像源
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://要写入的镜像源.cn"]
}
EOF
3.重启守护进程和docker引擎
sudo systemctl daemon-reload
sudo systemctl restart docker
  1. 测试镜像源配置成功
c 复制代码
sudo docker pull hello-world

成功截图

  1. 其他镜像源加速地址
名称 地址
Docker 中国官方镜像 https://registry.docker-cn.com
DaoCloud 镜像站 http://f1361db2.m.daocloud.io
Azure 中国镜像 https://dockerhub.azk8s.cn
科大镜像站 https://docker.mirrors.ustc.edu.cn
阿里云 https://ud6340vz.mirror.aliyuncs.com
七牛云 https://reg-mirror.qiniu.com
网易云(常用) https://hub-mirror.c.163.com
腾讯云 https://mirror.ccs.tencentyun.com

报错解决

  1. wsl中执行Ubuntu 报错:System has not been booted with systemd as init system (PID 1). Can't operate.

  2. wsl中执行Ubuntu 报错:Job for docker.service failed because the control process exited with error code.See "systemctl status docker.service" and "journalctl -xeu docker.service" for details.

    sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
    sudo apt reinstall docker-ce
    sudo rm -f /etc/docker/daemon.json
    sudo systemctl start docker
    sudo systemctl daemon-reload
    sudo systemctl restart docker


完全卸载Docker

  1. https://blog.csdn.net/hzblucky1314/article/details/135587650
  2. https://blog.csdn.net/weixin_45881248/article/details/134363865

少年,我观你骨骼清奇,颖悟绝伦,必成人中龙凤。 不如点赞·收藏·关注一波


🚩点此跳转到首行↩︎

参考博客

  1. ubuntu上使用阿里镜像源安装docker
  2. Docker配置阿里云加速器(2续)
  3. 待定引用
  4. 待定引用
  5. 待定引用
  6. 待定引用
  7. 待定引用
  8. 待定引用
相关推荐
jiunian_cn18 分钟前
【Linux】centos软件安装
linux·运维·centos
藥瓿亭28 分钟前
K8S认证|CKS题库+答案| 6. 创建 Secret
运维·ubuntu·docker·云原生·容器·kubernetes·cks
程序员JerrySUN29 分钟前
[特殊字符] 深入理解 Linux 内核进程管理:架构、核心函数与调度机制
java·linux·架构
孤寂大仙v32 分钟前
【计算机网络】非阻塞IO——select实现多路转接
linux·计算机网络
2302_8097983233 分钟前
【JavaWeb】Docker项目部署
java·运维·后端·青少年编程·docker·容器
嵌入式大圣35 分钟前
Neko虚拟浏览器远程协作方案:Docker+内网穿透技术部署实践
运维·docker·容器
派阿喵搞电子1 小时前
Ubuntu下有关UDP网络通信的指令
linux·服务器·网络
Evan_ZGYF丶1 小时前
【PCIe总线】 -- PCI、PCIe相关实现
linux·嵌入式·pcie·pci
舰长1151 小时前
Ubuntu挂载本地镜像源(像CentOS 一样挂载本地镜像源)
linux·ubuntu·centos
程序员JerrySUN1 小时前
全面理解 Linux 内核性能问题:分类、实战与调优策略
java·linux·运维·服务器·单片机