Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

學docker真是艱辛,初階學了幾天,進階主機管理就用了和前面同樣的時間,錯誤真的太多了。我如今就來記錄一下,我今天又遇到的問題。docker

一開始學的時候daemon沒有弄清楚,後來到了主機管理,也提了一下,但我都沒有解決得了,要學網絡時,發現必須得弄清楚了。教程通常都是兩條命令:json

systemctl daemon-reloadubuntu

systemctl restart docker.servicevim

可是ubuntu 14.04沒有systemctl命令,我一開始就用service ,upstart,cm2,等試了不行,後來靈機一動,我爲何不安一個呢!網絡

而後尚未daemon,我就安裝了 daemon。socket

1、service docker restart   stop:Unknow job    start: Unkonw job

第一條能運行成功了,第二條出錯,算了,無論他了,反正有service docker restart  阿里雲

加速器:針對Docker客戶端版本大於1.10的用戶,您能夠經過修改daemon配置文件/etc/docker/daemon.json來使用加速器:3d

而後我想用一個加速器,去阿里雲上申請了一個,但我沒有daemon配置文件。就在/etc/docker  下建立一個daemon.jsonunix

文件,其實有一個隱藏文件,.daemon.json.swp 隱藏文件,當我編輯daemon.json 時,出現以下提示:rest

我就vim -r daemon.json 添加了以下。

後來docker 就啓動不了了。

service docker restart

stop: Unknow instance、

start:job failed to start

 stop:Unknow job:docker

start: Unkonw job:docker

等錯誤,不要在su 模式下, 要在su - 模式下,就能夠。由於權限不夠,要給它賦予權限。

2、Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?  

安裝完daemon後,在/etc/systemd/system/docker/multi-user.target.wants/docker.service  配置文件中。

https://docs.docker.com/engine/admin/systemd/  

而後我就不知道改了什麼。就出現了

service docker restart

docker  stop/waiting

docker start/running, process 10051

service docker status

docker stop/running 

而後輸什麼命令錯誤都是:

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?  

而後經過查看/var/log/upstart/docker.log   ,感受確定是/var/run/docker.sock 有錯,

Docker使用socket進行客戶端和服務端的鏈接,unix:///var/run/docker.sock Unix端口,是默認的鏈接方式

就把daemon.json 文件刪了。

由於我以前在/etc/default/docker 配置文件下添加了一行DOCKER_OPTS=--registry-mirror-https://...mirror.aliyuncs.com

日誌說找不到,因而我就刪了。docker.sock 我沒動他,也就沒改。而後就行了。

今天真是亂亂的一天,寫的也很亂,明天我終於要開始學網絡了。