转载:http://mp.blog.youkuaiyun.com/postedit
在CI上调用此命令遇到问题:
test:
[exec] Couldn’t connect to Docker daemon at http+unix://var/run/docker.sock - is it running?
[exec]
[exec] If it’s at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
[exec] Result: 1
在网上搜了很久,终于解决了。
1. 编辑/etc/default/docker,修改下面的参数为
DOCKER_OPTS="-H tcp://127.0.0.1:4243 -H unix:///var/run/docker.sock"
- 1
- 2
2. 重启 docker 服务
网上都说用
$ sudo service docker restart
- 1
但是我这里不行,一运行就出现下面的结果
stop: Unknown job: docker
start: Unknown job: docker
- 1
- 2
我只好重启电脑
3. 检查并确定 Docker 运行在 localhost:4243
$ netstat -ant | grep 4243
tcp 0 0 127.0.0.1:4243 0.0.0.0:* LISTEN
- 1
- 2
- 3
4. 设置 DOCKER_HOST 环境变量,可以添加到 ~/.bashrc 文件中
export DOCKER_HOST=tcp://localhost:4243
- 1
运行命令
$ source ~/.bashrc
$ echo $DOCKER_HOST
tcp://localhost:4243
- 1
- 2
- 3
5. 重启电脑,问题解决
多谢博客:http://blog.youkuaiyun.com/kongxx/article/details/43481573,很大帮助