Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error running cadvisor docker package on Ubuntu 18.04.4 LTS #2387

Open
NichUK opened this issue Feb 5, 2020 · 6 comments
Open

Error running cadvisor docker package on Ubuntu 18.04.4 LTS #2387

NichUK opened this issue Feb 5, 2020 · 6 comments

Comments

@NichUK
Copy link

NichUK commented Feb 5, 2020

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.

@dashpole
Copy link
Collaborator

dashpole commented Feb 5, 2020

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.

@NichUK
Copy link
Author

NichUK commented Feb 6, 2020

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?

@stevegroom
Copy link

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.

@stevegroom
Copy link

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.

@plaidshirtakos
Copy link

I am facing the exact same error.

@Cethy
Copy link

Cethy commented Apr 14, 2021

FYI, if you install docker w/ snap (on ubuntu 18.04), /var/lib/docker does not exists because docker is set up differently.
To find the actual folder you need, run docker info | grep "Docker Root Dir:" (mine was /var/snap/docker/common/var-lib-docker).

and my docker-compose file:

  cadvisor:
    volumes:
      - /var/snap/docker/common/var-lib-docker:/var/lib/docker:ro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants