版本描述:
windows10
wsl版本 v1
Ubuntu-18.04
问题
在windows的wsl下使用docker run <容器id>的时候会报错:
1 | docker: Error response from daemon: OCI runtime create failed: container_linux.go:345: starting container process caused "process_linux.go:303: getting the final child's pid from pipe caused "EOF"": unknown. |
解决方法
参考issue:https://github.com/microsoft/WSL/issues/4385
或 docker文档:https://docs.docker.com/docker-for-windows/wsl/
将wsl升级到wsl2
官方参考文档:https://docs.microsoft.com/en-us/windows/wsl/install-win10#enable-the-virtual-machine-platform-optional-component
- Windows键+R,然后输入winver,回车
检查当前windows版本不低于19041
- 如果版本不满足条件,升级windows版本,目前想要使用wsl2必须要使用内部版本。
点击join the windows insider program,根据指引完成添加。
- 等待安装更新完成之后,可以使用wsl -l -v 指令
将ubuntu发行版设置为wsl2
以下命令在cmd或powershell中键入
- 查看发行版wsl版本:
- 设置为version 2
1> wsl --set-version Ubuntu-18.04 2
打开ubuntu 启动docker
- 以管理员身份运行ubuntu
如果不是以管理员身份运行会报如下错误:
1 2 3 4 5 6 7 | time="2020-04-22T17:50:13.830701400+08:00" level=warning msg="Running iptables --wait -t nat -L -n failed with message: `iptables v1.6.1: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)\nPerhaps iptables or your kernel needs to be upgraded.`, error: exit status 3" time="2020-04-22T17:50:14.763319500+08:00" level=info msg="stopping event stream following graceful shutdown" error="<nil>" module=libcontainerd namespace=moby time="2020-04-22T17:50:14.763644400+08:00" level=info msg="stopping event stream following graceful shutdown" error="context canceled" module=libcontainerd namespace=plugins.moby time="2020-04-22T17:50:14.763660900+08:00" level=info msg="stopping healthcheck following graceful shutdown" module=libcontainerd failed to start daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain DOCKER: iptables failed: iptables -t nat -N DOCKER: iptables v1.6.1: can't initialize iptables table `nat': Table does not exist (do you need to insmod?) Perhaps iptables or your kernel needs to be upgraded. (exit status 3) |
- 启动docker服务
1> sudo service docker start
- 启动容器
可以看到成功启动,且不会报错,问题解决。