解決CentOS6.4 Docker "Couldn't connect to Docker daemon ..." 問題


OS: CentOS6.4

#uname -r

2.6.32-504.1.3.el6.x86_64

安裝完畢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的解決方案。

於是查看docker的啟動腳本:vim /etc/rc.d/init.d/docker,在第50行可以看到啟動docker時執行的命令如下:$exec -d $other_args $DOCKER_STORAGE_OPTIONS &>> $logfile &  

從執行命令可以看出,可以帶一些自定義參數,如:$other_args $DOCKER_STORAGE_OPTIONS

為了解決目前遇到的問題,需要設置參數$other_args

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端口:

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

 

同時需要設置環境變量$DOCKER_HOST:

$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/

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM