WSL2用docker daemon(不用桌面版本的)麻烦吗?

wsl2安装

按照微软的指导文档,安装基本没问题。

docker安装


sudo apt-get update # 更新内核
sudo apt-get install ca-certificates curl gnupg #安装依赖

# 导入 Docker 官方 GPG 密钥
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

# docker仓库
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update # 更新内核

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo service docker start

# 安装docker
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

使用apt,替换 /etc/apt/sources.list,改成国内源即可加速,安装依赖,添加docker官方 GPG 密钥

至此,docker就可以用了! 比如:docker pull alpine

但是真的好用吗?

由于 docker.io 的访问不会那么流畅

几个踩坑点记录:

国内源替换,获得正常使用docker体验

$ cat /etc/docker/daemon.json
#在这里可以添加你喜欢的国内源:大公司的、一些云厂的
{
  "registry-mirrors": ["https://docker.xuanyuan.me"]
}

坑点:加速不可用

docker启动报错


sudo journalctl -u docker.service 

failed to start daemon: Error initializing network controller: error creating default "bridge" network: COMMAND_FAILED: 'python-nftables' failed: internal:0:0-0: Error: Could not process rule:  No such file or directory

临时解决:

{
  "registry-mirrors": ["..."],
  "experimental": true,
  "iptables": false
}

根据错误提示,卸载了nftable,安装python3-nftables,将会一直导致上诉docker启动报错

临时解决的  "experimental": true 不可用加速

需重装nftables(ubuntu的新的防火墙,替换fwd),使用nft命令查看,设置自动启动

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

jackie_05

oo

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值