【个人亲试最新】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. 待定引用
相关推荐
正在努力的小河1 小时前
Linux设备树简介
linux·运维·服务器
荣光波比1 小时前
Linux(十一)——LVM磁盘配额整理
linux·运维·云计算
LLLLYYYRRRRRTT1 小时前
WordPress (LNMP 架构) 一键部署 Playbook
linux·架构·ansible·mariadb
轻松Ai享生活2 小时前
crash 进程分析流程图
linux
大路谈数字化3 小时前
Centos中内存CPU硬盘的查询
linux·运维·centos
luoqice4 小时前
linux下查看 UDP Server 端口的启用情况
linux
倔强的石头_5 小时前
【Linux指南】动静态库与链接机制:从原理到实践
linux
程思扬5 小时前
Nextcloud容器化部署革新:Docker+Cpolar构建高效私有云远程访问新架构
docker·容器·架构
赏点剩饭7785 小时前
linux中的hostpath卷、nfs卷以及静态持久卷的区别
linux·运维·服务器
神鸟云6 小时前
DELL服务器 R系列 IPMI的配置
linux·运维·服务器·网络·边缘计算·pcdn