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

Cadvisor not showing Docker containers with Docker for Mac #1565

Open
anantMulesoft opened this issue Dec 27, 2016 · 16 comments
Open

Cadvisor not showing Docker containers with Docker for Mac #1565

anantMulesoft opened this issue Dec 27, 2016 · 16 comments

Comments

@anantMulesoft
Copy link

Dear CAdvisor team,

I am running Docker for Mac and have two containers running on my machine as shown below:

$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
38d9770aafd4 google/cadvisor "/usr/bin/cadvisor -l" 5 minutes ago Up 5 minutes 0.0.0.0:8080->8080/tcp cadvisor
32bff84b713a tutum/hello-world "/bin/sh -c 'php-fpm " 13 minutes ago Up 5 minutes 80/tcp goofy_einstein

However, when I log into the CAdvisor Web UI on localhost:8080 and click on Docker Containers I get the following error:

Cannot connect to the Docker daemon. Is the docker daemon running on this host?

Can you please let me know what is missing or whether this is a bug?

@ebuildy
Copy link
Contributor

ebuildy commented Dec 27, 2016

How did you run cadvisor?

For me:

 docker run \
  --volume=/:/rootfs:ro \
  --volume=/var/run:/var/run:rw \
  --volume=/sys:/sys:ro \
  --volume=/var/lib/docker/:/var/lib/docker:ro \
  --publish=8080:8080 \
  --detach=true \
  --name=cadvisor \
  google/cadvisor:latest

works fine.

@muralibala
Copy link

How do I run cAdvisor on a different port. I have Jenkins running on port 8080. This is what I have tried but i am not able to bring up the instance on 8090. TIA

sudo docker run
--volume=/:/rootfs:ro
--volume=/var/run:/var/run:rw
--volume=/sys:/sys:ro
--volume=/var/lib/docker/:/var/lib/docker:ro
--publish=8090:8080
--name=cadvisor
google/cadvisor:latest

@mohammedna
Copy link

docker run
--volume=/:/rootfs:ro
--volume=/var/run:/var/run:rw
--volume=/sys:/sys:ro
--volume=/var/lib/docker/:/var/lib/docker:ro
--publish=8090:8080
--detach=true
--name=cadvisor
google/cadvisor:latest

This works for me as well, make sure the port 8090 is not being blocked..

@SpyMachine
Copy link

I'm having this same problem MacOS 10.15.7 and Docker Desktop 2.4.0.0

@muhammedbasilsk
Copy link

@SpyMachine
I am facing issue in MacOS 10.15.7 and Docker Desktop 2.4.0.0

@POD666
Copy link
Contributor

POD666 commented Oct 29, 2020

+1, MacOS 10.15.5 and Docker Desktop 2.4.0.0, docker engine 19.03.13

At http://localhost:8080/docker/ I get:

failed to get docker info: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Looks like docker.sock in the mounted /var/run/ volume is a link to another location, could it be related?

# ls -la /var/run/
...
lrwxr-xr-x    1 root     root            79 Oct  4 14:48 docker-cli.sock -> /Users/<user>/Library/Containers/com.docker.docker/Data/docker-cli.sock
lrwxr-xr-x    1 root     root            75 Oct  4 14:48 docker.sock -> /Users/<user>/Library/Containers/com.docker.docker/Data/docker.sock

! UPD: Mounting docker.sock instead of /var/run/ resolved the issue for me:

volumes:
  ...
  - /var/run/docker.sock:/var/run/docker.sock:rw
  ...

@aks8m
Copy link

aks8m commented Oct 29, 2020

@POD666 your suggestion worked for me and removed the Docker daemon error that I was getting when going to http://cadvisor:8080/docker.

I still am having issues with directly accessing cadvisor stats via a container name (e.g., http://cadvisor:8080/docker/prometheus) - rather I need to have the long ID of the prometheus container (e.g., http://cadvisor:8080/docker/xxxxxxxxxxxxxxxxxxxxxxxxxx).

@soulmachine
Copy link

soulmachine commented Dec 2, 2020

I'm having the same issue on macOS Catalina 10.15.7 and Docker Desktop 2.5.0.1 with Docker engine 19.03.13

@Djiit
Copy link

Djiit commented Dec 9, 2020

@POD666 's solution fixed it for me.

@soulmachine
Copy link

@Djiit Can you share your full command?

@muhammedbasilsk
Copy link

@POD666 Awesome... It worked.

docker run -d --name=cadvisor -p 8080:8080 --volume=/var/run:/var/run:rw --volume=/sys:/sys:ro --volume=/var/lib/docker/:/var/lib/docker:ro --volume=/var/run/docker.sock:/var/run/docker.sock:rw google/cadvisor:latest

@Djiit
Copy link

Djiit commented Dec 9, 2020

@soulmachine same as @muhammedbasilsk !

@soulmachine
Copy link

Hi @Djiit and @muhammedbasilsk , the command above works, I can see my container on my MacBook now, thanks a lot!

@soulmachine
Copy link

soulmachine commented Dec 10, 2020

@muhammedbasilsk I change all rw to ro, the command still seems working.

docker run -d --name=cadvisor \
  -p 8080:8080 \
  --volume=/var/run:/var/run:ro \
  --volume=/sys:/sys:ro \
  --volume=/var/lib/docker/:/var/lib/docker:ro \
  --volume=/var/run/docker.sock:/var/run/docker.sock:ro \
  google/cadvisor:latest

@priyanka-raghavan-maersk

This fixed the issue for me as well on mac 13.1! thank you

@FavourDaniel
Copy link

adding this /var/run/docker.sock:/var/run/docker.sock:ro to my volume section worked for me, thanks everyone

High5Apps added a commit to High5Apps/organize-backend that referenced this issue Oct 23, 2024
- Used the following Dockerfile as the main example
  - https://github.com/oijkn/Docker-Raspberry-PI-Monitoring/blob/760528af93b2d5ce3a2025a6c7beb90f3dd3c27c/docker-compose.yml#L22-L44
  - Note that it differs from the docker command mentioned in the cAdvisor README quick-start due to the fixes mentioned further below
    - https://github.com/google/cadvisor?tab=readme-ov-file#quick-start-running-cadvisor-in-a-docker-container
- Fixed "Failed to get system UUID" error by adding `/etc/machine-id` volume mount
  - google/cadvisor#2157 (comment)
- Fixed container names not included on mac by adding `/var/run/docker.sock` volume mount
  - google/cadvisor#1565 (comment)
  - Note that `ro` was sufficient and `rw` wasn't needed as mentioned in google/cadvisor#1565 (comment)
- Fix cAdvisor high memory usage with oijkn/Docker-Raspberry-PI-Monitoring#34
- Note that every 5 minutes, two error messages are logged. This is a known issue with cAdvisor:v0.49.1 that will hopefully be fixed in a future release
  - google/cadvisor#3493
- Add cAdvisor metrics to the prometheus.yml file
  - I initially tried to use port 8081 in this file, but it didn't work. The following answer led me to realize that it needed to be port 8080, since 8081 is only used on the host machine's network, not within the docker routing network itself
  - https://stackoverflow.com/q/54397463
- Explanation of `privileged: true`
  - https://thelinuxcode.com/privileged-in-docker-compose-with-code-examples/
- cAdvisor docs on prometheus
  - https://github.com/google/cadvisor/blob/master/docs/storage/prometheus.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests