windows 10 安装ubuntu+docker(不安装desktop docker)步骤

发布时间 2023-11-13 22:49:08作者: tommickey

windows 10 安装ubuntu+docker(不安装desktop docker)步骤
1. 安装wsl2,ubuntu 22.04参考网络文档
2. powershell 里运行wsl
3. sudo -i
4. curl -fsSL https://get.docker.com -o get-docker.sh
5. sh get-docker.sh
6. service docker start
7. 在2.1通过脚本安装docker时,会出现下面这个问题 sudo service docker start显示[OK],但service docker status显示Docker is not running,导致docker服务一直无法启动?
运行dockerd后,查看报错信息
failed to start daemon: Error initializing network controller: error obtaining controller instance: unable to add return rule in DOCKER-ISOLATION-STAGE-1 chain: (iptables failed: iptables --wait -A DOCKER-ISOLATION-STAGE-1 -j RETURN: iptables v1.8.7 (nf_tables): RULE_APPEND failed (No such file or directory): rule in chain DOCKER-ISOLATION-STAGE-1
(exit status 4))
这是因为ubuntu系统使用了iptables-nft,而WSL2不支持导致的,使用下面命令修改:
sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
8. service docker start
9. service docker info