I'm trying to run up cadvisor to monitor docker containers on an Ubuntu 18.04.4 LTS machine.
Using the command I got from the cadvisor site:
sudo docker run --volume=/:/rootfs:ro --volume=/var/run:/var/run:ro --volume=/sys:/sys:ro --volume=/var/lib/docker/:/var/lib/docker:ro --volume=/dev/disk/:/dev/disk:ro --publish=8080:8080 --detach=true --name=cadvisor --privileged gcr.io/google-containers/cadvisor:latest
I repeatably get the error:
docker: Error response from daemon: error while creating mount source path '/var/lib/docker': mkdir /var/lib/docker: read-only file system.
My Docker version is 18.09.9 build 1752eb3 and has several containers running successfully on it.
It looks like cAdvisor is unable to mount /var/lib/docker because its filesystem is read-only. I don't think this is related to cAdvisor. Googling for your error brings up a few issues that may be related. I would start there.
It's a fresh clean install of Ubuntu, with Docker loaded as part of the install...
If the filesystem is set as read-only by that process, then that would seem to be a default, and if CAdvisor needs non-standard read/write access to it, then surely that's worth a documentation note, if nothing else?
The /var/lib/docker directory exists but is not readable to users that are added to the docker group.
ls -las /var/lib
...
4 drwx--x--x 14 root root 4096 Mar 8 19:59 docker
...
ls -las /var/run
...
0 drwx------ 5 root root 120 Mar 8 19:59 docker
4 -rw-r--r-- 1 root root 4 Mar 8 19:59 docker.pid
0 srw-rw---- 1 root docker 0 Mar 8 19:59 docker.sock
...
If I run sudo docker... --privileged=true that makes no difference.
OK,
I think I have it working now.
Re-reading https://github.com/google/cadvisor/blob/master/docs/running.md#centos-fedora-and-rhel it hints that /var/lib/docker access is not needed when using the privileged=true switch.
I removed /var/lib/docker from my docker-compose file:
cadvisor:
image: google/cadvisor:latest
container_name: cadvisor
command:
- privileged=true
ports:
- 8081:8080
volumes:
- /:/rootfs:ro
- /var/run:/var/run:ro
- /sys:/sys:ro
# - /var/lib/docker/:/var/lib/docker:ro
- /dev/disk/:/dev/disk:ro
Still have testing to do, but looks promising.
I am facing the exact same error.
Most helpful comment
OK,
I think I have it working now.
Re-reading https://github.com/google/cadvisor/blob/master/docs/running.md#centos-fedora-and-rhel it hints that /var/lib/docker access is not needed when using the privileged=true switch.
I removed /var/lib/docker from my docker-compose file:
Still have testing to do, but looks promising.