Search code examples
ubuntucadvisor

cAdvisor not rendering UI on a remote IP Address


I have a VPS(Ubuntu 14.04 LTS) where I have installed cAdvisor using the standard command as mentioned in the documentation -

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=2020:2020   --detach=true   --name=cadvisor   google/cadvisor:latest --logtostderr

Doing a docker ps shows a container with name cAdvisor up and running.

Here are the syslogs -

tail -f /var/log/syslog
Mar 19 11:56:28 localhost docker[6250]: time="2016-03-19T11:56:28.163095600Z" level=info msg="GET /containers/d7ea5b23a9adef46512d0e6558705b67abf76ca7e659b876e96b39c2671d9d4e/json"
Mar 19 11:56:28 localhost docker[6250]: time="2016-03-19T11:56:28.164485455Z" level=info msg="GET /containers/d7ea5b23a9adef46512d0e6558705b67abf76ca7e659b876e96b39c2671d9d4e/json"
Mar 19 11:56:28 localhost docker[6250]: time="2016-03-19T11:56:28.179509677Z" level=info msg="GET /containers/324eff724ff4dc37b560d69de4b9d55baf3ee2d8a563697e14d345e0e7ca5d0e/json"
Mar 19 11:56:28 localhost docker[6250]: time="2016-03-19T11:56:28.180811473Z" level=info msg="GET /containers/324eff724ff4dc37b560d69de4b9d55baf3ee2d8a563697e14d345e0e7ca5d0e/json"
Mar 19 11:56:28 localhost docker[6250]: time="2016-03-19T11:56:28.187200355Z" level=info msg="GET /containers/1ca28d92213568732efde8a935ea935b8a82d235e2585751f3c60d191e9d5557/json"
Mar 19 11:56:28 localhost docker[6250]: time="2016-03-19T11:56:28.188571105Z" level=info msg="GET /containers/1ca28d92213568732efde8a935ea935b8a82d235e2585751f3c60d191e9d5557/json"
Mar 19 11:56:28 localhost docker[6250]: time="2016-03-19T11:56:28.192465837Z" level=info msg="GET /containers/99b3e78062f67c5b5dabdddab4091449e4b81b1ad067426618b4dcbfec2e2157/json"
Mar 19 11:56:28 localhost docker[6250]: time="2016-03-19T11:56:28.193462558Z" level=info msg="GET /containers/99b3e78062f67c5b5dabdddab4091449e4b81b1ad067426618b4dcbfec2e2157/json"
Mar 19 11:56:28 localhost docker[6250]: time="2016-03-19T11:56:28.195544729Z" level=info msg="GET /containers/85df2cf4dde10d08cd598485975b330cdd00d04c9426616f61e28729e74f8e56/json"
Mar 19 11:56:28 localhost docker[6250]: time="2016-03-19T11:56:28.196908541Z" level=info msg="GET /containers/85df2cf4dde10d08cd598485975b330cdd00d04c9426616f61e28729e74f8e56/json"

Everything going fine up until now.

  1. I open the Address in browser, no response.
  2. I do a ssh tunnel and map 2020 of remote to my 2020 of local machine and open localhost:2020 no response.
  3. The IP Address of the container running cAdvisor is 172.17.0.9 doing an nc -vz 172.17.0.9 2020 returns connection refused.

    172.17.0.9: inverse host lookup failed: Unknown host (UNKNOWN) [172.17.0.9] 2020 (?) : Connection refused

Any thoughts on whats gone wrong?

TIA.


Solution

  • Your --publish=2020:2020 is just the option for Docker container, which means it ports the container's 2020 to VM's 2020.

    But inside the container, the cadvisor program is default listening to 8080, not 2020.

    So, you should add cadvisor cmd option: --port=2020 https://github.com/google/cadvisor/blob/master/docs%2Fruntime_options.md

    The whole cmd looks like this:

    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=2020:2020 \
      --detach=true \
      --name=cadvisor \
      google/cadvisor:latest \
      --logtostderr \
      --port=2020