Search code examples
windowsdockerwindows-subsystem-for-linuxdocker-desktop

Error "readlink /var/lib/docker/overlay2/l: invalid argument"


I'm getting this error when executing docker run --rm -it alpine /bin/sh:

latest: Pulling from library/alpine
8921db27df28: Already exists
Digest: sha256:f271e74b17ced29b915d351685fd4644785c6d1559dd1f2d4189a5e851ef753a
Status: Downloaded newer image for alpine:latest
ERRO[0040] error waiting for container: context canceled docker: Error response from daemon: Failed to inspect container 9919d1156d3960b46bca915bdf3b1d2320f463edbea5c39cacdc8b29640534fe: Error response from daemon: readlink /var/lib/docker/overlay2/l: invalid argument.

I'm using Docker Desktop on Windows with WSL 2.

I've tried docker rmi alpine:latest, but the error persisted.

I've tried docker system prune --all, but it didn't help.


Solution

  • Some of workarounds I've used:

    1. When using the Docker command line, I specified a different version of the image. Instead of alpine:latest, I used alpine:3.16, and it helped.
    2. I used Hyper-V instead of WSL 2 (Docker DesktopSettingsGeneral. Untick "Use the WSL 2 based engine")
    3. As suggested in this answer, I reset Docker WSL 2 data. But instead of resetting all Docker data, it is possible to clear only WSL 2: Docker DesktopTroubleshoot (it is the "bug" icon next to the Settings icon) → Clean/Purge data, select WSL 2, and press Delete.