【个人亲试最新】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. 待定引用
相关推荐
人猿泰飞32 分钟前
在Ubuntu-22.04.5中安装ONLYOFFICE DocSpace(协作空间)【注意:安装失败,谨慎参考!】
java·linux·运维·python·ubuntu·项目管理·onlyoffice
CAE虚拟与现实34 分钟前
修改wsl中发行版Ubuntu的主机名
linux·运维·ubuntu·wsl·wsl2·修改主机名
开发小能手-roy37 分钟前
Ubuntu服务器性能调优指南:从基础工具到系统稳定性提升
linux·运维·服务器·ubuntu
潘yi.44 分钟前
Shell编程之正则表达式与文本处理器
linux·运维·正则表达式
涛涛讲AI1 小时前
wkhtmltopdf 实现批量对网页转为图片的好工具,快速实现大量卡片制作
linux·服务器·windows·windows效率工具
破刺不会编程1 小时前
什么是进程?
linux·运维·服务器
❀͜͡傀儡师1 小时前
docker 安装TDengine 时序数据库
docker·时序数据库·tdengine
laimaxgg2 小时前
Docker Hub 创建私人镜像仓库
运维·服务器·docker·容器
大数据魔法师2 小时前
Redis(一) - Redis安装教程(Windows + Linux)
linux·windows·redis
Y1anoohh2 小时前
驱动学习专栏--字符设备驱动篇--2_字符设备注册与注销
linux·c语言·驱动开发·学习