当前位置: 首页 > news >正文

wsl中迁移ubuntu24.04后docker后无法启动的问题

wsl中迁移ubuntu24.04后docker后无法启动的问题

发生原因

我将外网wsl2中的Ubuntu24.04迁移到内网(无网络)电脑中,发现原本安装的docker无法启动,
在使用 apt-get install docker-ce docker-ce-cli containerd.io重新安装后依然不行

NOTE:迁移后软件会失去注册信息,运行会提示命令未注册,所以需要重新安装。其实系统中已经包含了相关安装包,所以不会联网下载

原因

查看Docker的日志vim /var/log/docker.log显示如下的错误

time="2025-04-09T10:29:59.904691194+08:00" level=info msg="Loading containers: start."
time="2025-04-09T10:30:00.055889722+08:00" level=info msg="stopping event stream following graceful shutdown" error="<nil>" module=libcontainerd namespace=moby
time="2025-04-09T10:30:00.056182637+08:00" level=info msg="stopping healthcheck following graceful shutdown" module=libcontainerd
time="2025-04-09T10:30:00.056254606+08:00" level=info msg="stopping event stream following graceful shutdown" error="context canceled" module=libcontainerd namespace=plugins.moby
failed to start daemon: Error initializing network controller: error obtaining controller instance: failed to register "bridge" driver: failed to add jump rules to ipv4 NAT table: failed to append jump rules to nat-PREROUTING:  (iptables failed: iptables --wait -t nat -A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER: Warning: Extension addrtype revision 0 not supported, missing kernel module?
iptables v1.8.10 (nf_tables):  CHAIN_ADD failed (No such file or directory): chain PREROUTING
 (exit status 4))

原因是由于迁移后ubuntu系统使用了iptables-nft,而WSL2不支持导致的。

修复

修改为iptables-legacy即可

 root@DESKTOP-5DTRJV0:/home/friday/apt-offline# update-alternatives --config iptables
There are 2 choices for the alternative iptables (providing /usr/sbin/iptables).

  Selection    Path                       Priority   Status
------------------------------------------------------------
* 0            /usr/sbin/iptables-nft      20        auto mode
  1            /usr/sbin/iptables-legacy   10        manual mode
  2            /usr/sbin/iptables-nft      20        manual mode

Press <enter> to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/sbin/iptables-legacy to provide /usr/sbin/iptables (iptables) in manual mode
root@DESKTOP-5DTRJV0:/home/friday/apt-offline# service docker start
 * Starting Docker: docker                                               [ OK ]                                                                                                                                              
root@DESKTOP-5DTRJV0:/home/friday/apt-offline# docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

相关文章:

  • 聊一聊接口测试时需要注意哪些
  • FPAG_BUFFER学习
  • Elasticsearch入门指南(一)
  • zsh: command not found - 鸿蒙 HarmonyOS Next
  • Java 中 JSON 处理库将对象含二进制数组转换为 JSON 字符串
  • ROS2——foxy apt打包离线安装deb包
  • YOLOv11训练中精准率召回率与mAP@0.5的动态变化分析
  • 配置与管理代理服务器
  • openEuler-22.03-LTS-SP3 编译安装 Greenplum-db 6.20.0
  • 【检测手机有无网络】
  • 自动化测试——selenium
  • 【python】针对Selenium中弹框信息无法定位的问题,以下是综合解决方案及注意事项:
  • Trae + LangGPT 生成结构化 Prompt
  • C++ 时间库和线程库学习笔记(Chrono 与 Thread)
  • C++ 中的双指针技巧:高效解决数组和链表问题
  • 华为openEuler欧拉系统
  • unity运行时进行录制并保存(可进行二次加载包含场景中生成动态物体)
  • AMS 启动流程管理进程与Binder的关联
  • LeetCode.234. 回文链表
  • 峰飞航空与合肥开启全面合作,打造先进空中立体多维交通运输生态
  • 有哪些做应援的网站/重庆百度seo整站优化
  • 怎么免费建网站/厦门专业做优化的公司
  • 邯郸网站建设策划方案/网络营销推广渠道
  • 网站设计 cdc/色盲测试图看图技巧
  • 南昌网站优化方案/商丘seo教程
  • 怎么自己制作月饼/站长工具seo