【个人亲试最新】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. 待定引用
相关推荐
likfishdn10 分钟前
Linux的文件与目录管理
linux·运维·服务器
chian-ocean29 分钟前
Linux 文件缓冲区:高效数据访问的幕后推手
linux·运维·服务器
加油=^_^=31 分钟前
【Linux】进程优先级 | 进程调度(三)
linux·运维·服务器
若云止水40 分钟前
Ubuntu 下 nginx-1.24.0 源码分析 - ngx_init_cycle 函数 - 详解(4)
数据库·nginx·ubuntu
Dontla1 小时前
Docker run --add-host参数解析(在容器启动时向/etc/hosts文件中添加自定义的主机名与IP映射)(适用于临时调试或测试)
tcp/ip·docker·容器
西西小飞龙1 小时前
Docker和K8S中pod、services、container的介绍和关系
docker·容器·kubernetes
吃汤圆的抹香鲸1 小时前
GoLand 安装包 绿色版 Win,Mac,Linux 包含IntelliJ全家桶 专为Go语言设计的集成开发环境(IDE)
linux·windows·macos·go·intellij-idea·go1.19
追寻光1 小时前
Cannot find a valid baseurl for repo: base/7/x86_64
linux
元气满满的热码式1 小时前
Docker数据卷操作实战
linux·运维·docker·云原生·容器
kngines1 小时前
【实战 ES】实战 Elasticsearch:快速上手与深度实践-1.3.1单节点安装(Docker与手动部署)
大数据·elasticsearch·docker