Cargo uses too much memory being run in QEMU

I've used GitHub actions to build some Rust code for ARM and PPC using docker and qemu. It worked well for a while but recently every build has started to fail while cargo fetched crates.io index. I reproduced it locally on my ARM machine by:

# docker run --cap-add syslog  --rm -ti --platform=linux/amd64 rust
# cargo install cargo
Updating crates.io index
Killed Fetch [======>                  ]  30.43%, 3.33MiB/s

Any platform but native is good to reproduce. My docker on Mac installation has 10GB of RAM (I think it is more than GitHub action runners provide) and dmesg shows that cargo used almost all of them before being killed.

Do you have any idea what is happening here? Is any QEMU update which made things worse just happened? How I can try to work around the problem, maybe I could fetch crates.io index locally and mount it inside the container?

There's net.git-fetch-with-cli option that uses command-line git instead of libgit2. Maybe that will help?

@kornel thank you, it fixed the issue, at least locally!

EDIT: It works on GitHub too! Thank you!