WSL: docker cannot start after installing linux-msft-wsl-6.6.y
Windows Version
Microsoft Windows [Version 10.0.22631.3810]
WSL Version
2.2.4.0
Are you using WSL 1 or WSL 2?
- WSL 2
- WSL 1
Kernel Version
6.6.36.3+
Distro Version
Debian 11
Other Software
No response
Repro Steps
1)Install Docker in Debian (not in Windows). 2)Run “docker image ls”. All good. 3)Compile and install linux-msft-wsl-6.6.y kernel from Git. 4)Run “docker image ls”. Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Expected Behavior
Run “docker image ls”. It reports all installed images.
Actual Behavior
Run “docker image ls”. It reports Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Diagnostic Logs
I tried command “dockerd” and here is the error: INFO[2024-07-03T14:56:01.609154816+02:00] Starting up INFO[2024-07-03T14:56:01.768529492+02:00] [graphdriver] using prior storage driver: overlay2 INFO[2024-07-03T14:56:01.769406490+02:00] Loading containers: start. WARN[2024-07-03T14:56:02.295454881+02:00] Could not load necessary modules for IPSEC rules: protocol not supported INFO[2024-07-03T14:56:02.304720573+02:00] Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address INFO[2024-07-03T14:56:02.318493061+02:00] stopping event stream following graceful shutdown error=“<nil>” module=libcontainerd namespace=moby failed to start daemon: Error initializing network controller: error creating default “bridge” network: Failed to Setup IP tables: Unable to enable NAT rule: (iptables failed: iptables --wait -t nat -I POSTROUTING -s 172.17.0.0/16 ! -o docker0 -j MASQUERADE: iptables v1.8.7 (nf_tables): Chain ‘MASQUERADE’ does not exist Try `iptables -h’ or ‘iptables --help’ for more information. (exit status 2))
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 3
- Comments: 22
Hi all o/
This is due to config changes that happened in the WSL2 kernel release linux-msft-wsl-6.6.36.3. Some of the configs Docker requires were changed to be loadable modules instead of their previously built-in state.
WSL2 now has loadable module support ( yay \o/ ), except when using a custom kernel, at least for now. By module support I mean using ‘modprobe’ or modules auto-loading when they’re called (i.e. running ‘dockerd’ should load all the modules it needs to run and will do so in an upcoming WSL release when using its default kernel linux-msft-wsl-6.6.36.3.) You can still use insmod to load modules individually with a custom kernel. Or you can edit the kernel config file to set all loadable modules you want to be built-in before compiling your kernel (recommended route).
Fwiw, you can use the old 5.15 config ( 5.15 config-wsl (x86) / 5.15 config-wsl-arm64 ) to build linux-msft-wsl-6.6.36.3 and go back to your prior config state if you’d like. You will just need to select values for any newly added configs between 5.15 and 6.6 when building.
When running the Docker check-config.sh (found under docker.docs Kernel Compatibility), we can see which configs are now modules and should either be set to built-in in your configs or you can always load them individually:
I made sure Docker is running with this kernel release with the recommended config changes and by default in the upcoming WSL release that will include the kernel linux-msft-wsl-6.6.36.3. For extra reference, here are the modules that get auto loaded when I run ‘dockerd’ in the upcoming WSL release:
I added a new note to the linux-msft-wsl-6.6.36.3 release to hopefully bring better attention to these config changes.
Thank you so much for being early users of this WSL2 kernel, testing, and reporting! I hope this information helps. 😃
Here is the Docker check-config.sh (found under docker.docs Kernel Compatibility).
At least, you must modify follow configs in Microsoft/config-wsl from ‘m’ to ‘y’: CONFIG_BRIDGE=y CONFIG_BRIDGE_NETFILTER=y CONFIG_NFT_COMPAT=y CONFIG_NETFILTER_XT_NAT=y CONFIG_NETFILTER_XT_TARGET_MASQUERADE=y CONFIG_NETFILTER_XT_MATCH_ADDRTYPE=y CONFIG_NETFILTER_XT_MATCH_CONNTRACK=y
The above modification works well for me.
After rebuilding the kernel and login in WSL, you need run follow scripts:
sudo systemctl stop dockersudo ip link del docker0sudo rm -rf /var/lib/docker/networksudo systemctl start dockerIf an error such like “error locating sandbox id 32791b12df33f576fa34a88cc67ceb89e3d8c21582a47ccc5532eb5414f4010f: sandbox 32791b12df33f576fa34a88cc67ceb89e3d8c21582a47ccc5532eb5414f4010f not found” occurred, you need use
docker rm xxxto remove your existed containers and rerun them withdocker run -dti xxx.Also, you can modify more configs as you need: CONFIG_NETFILTER_XT_MARK=y
CONFIG_IP_NF_IPTABLES=y CONFIG_IP_NF_FILTER=y CONFIG_IP_NF_NAT=y CONFIG_IP_NF_TARGET_MASQUERADE=y CONFIG_IP_NF_MANGLE=y
CONFIG_IP_VS=y CONFIG_NETFILTER_XT_MATCH_IPVS=y
CONFIG_XFRM_USER=y CONFIG_XFRM_ALGO=y CONFIG_INET_ESP=y
CONFIG_IP_VS_RR=y CONFIG_NET_CLS_CGROUP=y CONFIG_IP_NF_TARGET_REDIRECT=y
CONFIG_IPVLAN=y CONFIG_MACVLAN=y CONFIG_DUMMY=y
CONFIG_NF_NAT_FTP=y CONFIG_NF_CONNTRACK_FTP=y CONFIG_NF_NAT_TFTP=y CONFIG_NF_CONNTRACK_TFTP=y
CONFIG_BTRFS_FS=y
config-wsl config-wsl-6.6.36.3.txt
_Originally posted by @bit-hope in https://github.com/microsoft/WSL/issues/11771#issuecomment-2272556114_
https://gist.github.com/eapotapov/e64d8ce1d35064cf0dcd0dcd57577bdf
I’ve merged the 5.15 config into the existing 6.6 configuration. Whenever there was a “=y” in 5.15 and a “=m” in 6.6 for the same variable, it is now “=y” in the config.
Use it in ./Microsoft/config-wsl
Additionally, there were a couple of variables present in 5.15 but missing in 6.6 that I have added. I’m not sure if they are necessary, but I think they won’t hurt.
I started trying to compile the kernel because I wanted to enable eBPF. I was using this article for guidance. The variables mentioned there are also added (with “=y” everywhere instead of “=m”).
I just checked, and both eBPF and Docker Desktop are working.
Still, I’m not sure if this is a reliable solution, but it works for now. I will update in a week or so to confirm its reliability.
I can confirm that using the config-wsl file from linux-msft-wsl-6.1.y fixed the issue. Thank you all for your help!
Came across this issue myself and found an easy appraoch to solve it: https://blog.thetechcorner.sk/posts/Update-WSL2-kernel-to-6-6-x/
Credits to and big thanks to @eapotapov and @ard3ny 🙏🏼
I’m having trouble getting docker to start using a custom built
5.15.153.1kernel. I rebuilt the kernel in order to enable webcam support and loading that built kernel vis .wslconfig (camera works as expected)— but now docker won’t start up and it keeps looping asking for elevated access to update wsl. I haven’t been able to find anyone experiencing a similar issue.In the end I cancel out and get this:
wsl update failed: updating wsl: elevated update failed: the operating system denied access to the specified fileI’m pretty sure that this has something to do with the custom built image I made but I’m not well versed with building and using the kernel. Anyone have any sage advice on how to properly rebuild 5.15.153.1 and what I need to set the config variables to so that docker works? Any breadcrumbs would certainly help! TIA.
@mihaiflorinpopa once WSL releases with the 6.6 kernel, the kernel and modules will be pre-packaged and automatically apply when updating to it. Make sure to remove the “kernel=<path to kernel>” from your .wslconfig for the default kernel to be used and module support to be enabled. You’ll be able to find the modules under /lib/modules/.
Hopefully the next WSL release and with the default 6.6 kernel will do everything you need! If not and you still find needing a custom kernel, remember module support will continue to be disabled with custom kernels (at least for now), so use a kernel config with everything you need built in (i.e. the last 5.15 config or your own custom file).
@bs340248 you need to install the modules also. Docker is not finding the
br_netfiltermodule. Runjournalctl -u dockerfor details, orjournal -xeu docker.For older kernels the module is builtin: