Welcome to the Linux Foundation Forum!

Prometheus LFS241 - Lab 8 vs WSL

!!! Warning for future LFS241/PCA students using WSL to do labs

The Lab 8.1 instructs you to run cAdvisor with following volume mounts

docker run -d --name cadvisor -h cadvisor --net lab \
-v /:/rootfs:ro \
-v /var/run:/var/run:ro \
-v /sys:/sys:ro \
-v /var/lib/docker/:/var/lib/docker:ro \
-v /dev/disk/:/dev/disk:ro \
gcr.io/cadvisor/cadvisor:v0.52.1

If you're doing this lab on WSL, this will fail to connect to the docker daemon.

$ docker logs cadvisor 2>&1 | grep -i "fail"
I0915 09:13:49.946597       1 factory.go:221] Registration of the docker container factory failed: failed to validate Docker info: failed to detect Docker info: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

When cAdvisor fails to communicate with Docker Daemon via its socket, you won't be able to test Lab 8.3, because name or image parameters won't be available.

Even when you run the supported Ubuntu 24.04 within WSL, the problem is WSL has its own location for the docker.sock

$ echo $DOCKER_HOST
unix:///mnt/wsl/shared-docker/docker.sock

To fix this, make sure to add following volume mount to the cAdvisor run command:

 -v /mnt/wsl/shared-docker/docker.sock:/var/run/docker.sock:ro

Categories

Upcoming Training