解决CentOS6.4 Docker "Couldn't connect to Docker daemon ..." 问题

OS: CentOS6.4docker

#uname -rvim

2.6.32-504.1.3.el6.x86_64bash

安装完毕fig,并完成相应配置时执行以下命令出错(fig安装参见:http://www.fig.sh/):网络

#fig up
Couldn't connect to Docker daemon at http+unix://var/run/docker.sock - is it running? If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

 

查询相关网络资料,只有关于CentOS7的解决方案。app

因而查看docker的启动脚本:vim /etc/rc.d/init.d/docker,在第50行能够看到启动docker时执行的命令以下:$exec -d $other_args $DOCKER_STORAGE_OPTIONS &>> $logfile &  tcp

从执行命令能够看出,能够带一些自定义参数,如:$other_args $DOCKER_STORAGE_OPTIONSspa

为了解决目前遇到的问题,须要设置参数$other_args.net

vim /etc/sysconfig/docker-storage
# /etc/sysconfig/docker
#
# Other arguments to pass to the docker daemon process
# These will be parsed by the sysv initscript and appended
# to the arguments list passed to docker -d

other_args="-H tcp://127.0.0.1:4243 -H unix:///var/run/docker.sock"

重启docker 服务并查看docker服务是否监听了4243端口:unix

#service docker restart
#netstat -anpt | grep 4243
tcp        0      0 127.0.0.1:4243              0.0.0.0:*                   LISTEN      7760/docker  

 

同时须要设置环境变量$DOCKER_HOST:rest

$vim ~/.bashrc
export DOCKER_HOST=tcp://localhost:4243

 

在执行fig up时已经ok。

 

参考:

Ubuntu上的解决办法:http://blog.csdn.net/kongxx/article/details/43481573#comments

CentOS7上的解决办法:https://docs.docker.com/articles/systemd/

相关文章
相关标签/搜索