【个人亲试最新】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. 待定引用
相关推荐
shelby_loo25 分钟前
通过 Docker 部署 WordPress 服务器
服务器·docker·容器
DREAM依旧41 分钟前
《深入了解 Linux 操作系统》
linux
阿赭ochre1 小时前
Linux环境变量&&进程地址空间
linux·服务器
Iceberg_wWzZ1 小时前
数据结构(Day14)
linux·c语言·数据结构·算法
minsin1 小时前
【linux】【docker】Docker默认网段配置导致无法访问
docker
可儿·四系桜1 小时前
如何在多台Linux虚拟机上安装和配置Zookeeper集群
linux·服务器·zookeeper
Flying_Fish_roe1 小时前
linux-软件包管理-包管理工具(Debian 系)
linux·运维·debian
大广-全栈开发2 小时前
centos 7 安装gitlab
linux·git·centos
666786662 小时前
Mysql高级篇(中)—— SQL优化
linux·运维·服务器·数据库·sql·mysql
宇宙第一小趴菜3 小时前
虚拟机安装xubuntu
linux·服务器·vmware