欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  网络运营

docker images,info,-d等命令报错的解决方法

程序员文章站 2022-07-20 22:09:20
一、发现问题 楼主不管输入那个命令,都出现了: fata[0000] cannot connect to the docker daemon. is 'do...

一、发现问题

楼主不管输入那个命令,都出现了:

fata[0000] cannot connect to the docker daemon. is 'docker -d' running on this host? 

二、解决方法

以及类似的错误,就连docker version命令都报错了,楼主开始找啊找,找到了好多东西,结果发现没一个能行的,最后楼主使用这样的命令:

# vim /etc/default/docker 

在该文件中添加如下内容:

docker_opts="-h unix:///var/run/docker.sock -h 0.0.0.0:5555" 
# service docker restart 

这样就行了..我也不知道怎么样就行了.真的好神奇.

楼主赶快使用了一下

syx@syx-vb:~$ docker version 
client version: 1.6.2 
client api version: 1.18 
go version (client): go1.3.3 
git commit (client): 7c8fca2 
os/arch (client): linux/amd64 
server version: 1.6.2 
server api version: 1.18 
go version (server): go1.3.3 
git commit (server): 7c8fca2 
os/arch (server): linux/amd64 

好神奇,终于可以了,楼主赶快把docker升级到最新版本.

$ sudo add-apt-repository ppa:docker-maint/testing 
$ sudo apt-get update 
$ sudo apt-get install docker.io 

楼主这样就行了一次,然后就又不行了楼主开始找原因,这次楼主问了问别了,别人说在ubuntu下安装一个devicemapper

楼主使用的命令如下:

root@syx-vb:~# apt-get install -y libdevmapper-dev 

还是不行啊

root@syx-vb:~# service docker restart  
root@syx-vb:~# docker version  
root@syx-vb:~# docker version 
client version: 1.7.0-dev 
client api version: 1.19 
go version (client): go1.4.2 
git commit (client): 9234460 
os/arch (client): linux/amd64 
fata[0000] get http:///var/run/docker.sock/v1.19/version: read unix /var/run/docker.sock: connection reset by peer. are you trying to connect to a tls-enabled daemon without tls? 

楼主英语不行,看不懂是啥意思,接着问.

人家告诉楼主使用docker -d来看看:

root@syx-vb:~# docker -d 
info[0000] listening for http on unix (/var/run/docker.sock) 
fata[0000] error starting daemon: error initializing graphdriver: "/var/lib/docker" contains other graphdrivers: devicemapper; please cleanup or explicitly choose storage driver (-s <driver>) 

看不懂,接着问大神!!!
大神说了把/var/lib/docker下的devicemapper清掉,楼主一看:

root@syx-vb:/var/lib/docker# ls 
aufs containers devicemapper graph init linkgraph.db repositories-aufs repositories-devicemapper tmp trust volumes 

还真有这个目录,于是使用:

root@syx-vb:/var/lib/docker# rm -r devicemapper/ 

接着:

root@syx-vb:/var/lib/docker# docker version 
client version: 1.7.0-dev 
client api version: 1.19 
go version (client): go1.4.2 
git commit (client): 9234460 
os/arch (client): linux/amd64 
fata[0000] cannot connect to the docker daemon. is 'docker -d' running on this host? 

怎么还是不行!!

这个时候楼主重启了一下docker服务,居然就好了。

root@syx-vb:/var/lib/docker# service docker restart 
root@syx-vb:/var/lib/docker# docker version 

总结

好了,终于解决了,以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能有所帮助,如果有疑问大家可以留言交流。