I have a problem with my lxc/lxd container not being able to fetch package/network dependencies from the internet. Larger downloads get interrupted with peer disconnects.
I came across the error while trying to use Snapcraft on an Ubuntu 22.10 wsl installation, snapcraft uses lxd internally to perform build instructions. For brievity I reproduced the errror with the following minimum example.
echo -e "[boot]\nsystemd=true" | sudo tee /etc/wsl.conf > /dev/null
sudo apt-get update && sudo apt-get upgrade
wsl.exe --shutdown
sudo snap install lxd
sudo lxd init
sudo lxc launch images:ubuntu/focal wired-bluejay
sudo lxc exec wired-bluejay -- curl -o dart-sdk-linux-x64.zip https://storage.googleapis.com/flutter_infra_release/flutter/472e34cbbcd461c748973e7e735558ab200d4f5e/dart-sdk-linux-x64.zip
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
8 246M 8 20.8M 0 0 2780k 0 0:01:30 0:00:07 0:01:23 2951k
curl: (56) OpenSSL SSL_read: Connection reset by peer, errno 104
^ simple illustration of the problem
The problem only seems to manifest inside of the lxc container, image downloads like pulling ubuntu/focal
works without a problem. curl is just an example but happens with also with git.
I collected some more information in this gist w.r.t network configuration and tcpdumps: https://gist.github.com/phr34k/334c1c34fd519165cfede0eeaf382e7b
The problem is intermittend appears specific to wsl, occurs on two out of three wireless network that I've access to. Including regular my home network. The problem does not occur on a virtual box instance on the same machine.
Most github issues that reference changing mtu or upgrading wireless network drivers. I tried most solutions but didn't work. I'd appreciate if anybody has a solution or some pointers of what I can try.
- https://janovesk.com/wsl/2022/02/15/wsl2-and-mtu.html
- How to fix git error: RPC failed; curl 56 GnuTLS
- Using a socks proxy with git for the http transport
Bug reports:
- https://github.com/microsoft/WSL/issues/9427
- https://github.com/lxc/lxd/issues/11246
- https://discuss.linuxcontainers.org/t/curl-git-dont-work-properly-inside-an-lxd-container-on-wsl-ubuntu-instance-and-disconnects-frequently/16036
Edit:
- As an expiriment I setup a socks5 proxy and use that to connect from inside lxd, made curl stable. Suggesting it's not the internet connection in general but some kind of environmental/network settings related.