我有一个VPS(Ubuntu 14.04 LTS),我已经使用文档中提到的标准命令安装了cAdvisor -
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
执行docker ps
会显示名为cAdvisor且已运行的容器。
以下是系统日志 -
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"
到目前为止,一切都很顺利。
localhost:2020
没有响应。 运行cAdvisor的容器的IP地址为172.17.0.9
,nc -vz 172.17.0.9 2020
返回连接被拒绝。
172.17.0.9:反向主机查找失败:未知主机 (UNKNOWN)[172.17.0.9] 2020(?):连接被拒绝
关于什么出错的任何想法?
TIA。
答案 0 :(得分:0)
您的--publish=2020:2020
只是Docker容器的选项,这意味着它将容器的2020移植到VM的2020.
但是在容器内部,cadvisor
程序默认监听8080
,而不是2020
。
因此,您应添加cadvisor
cmd选项:--port=2020
https://github.com/google/cadvisor/blob/master/docs%2Fruntime_options.md
整个cmd看起来像这样:
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