Docker无法连接到docker守护程序

本文翻译自:Docker can’t connect to docker daemon

After I update my Docker version to 0.8.0 , I get an error message while entering sudo docker version : 在我将Docker版本更新到0.8.0 ,我在输入sudo docker version时收到错误消息:

Client version: 0.8.0
Go version (client): go1.2
Git commit (client): cc3a8c8
2014/02/19 12:54:16 Can't connect to docker daemon. Is 'docker -d' running on this host?

And I’ve followed the instructions and entered command sudo docker -d , and I got this: 我按照说明进入了命令sudo docker -d ,我得到了这个:

[/var/lib/docker|2462000b] +job initserver()
[/var/lib/docker|2462000b.initserver()] Creating server
open /var/lib/docker/aufs/layers/cf2414da53f9bcfaa48bc3d58360d7f1cfd3784e4fe51fbef95197709dfc285d: no such file or directory[/var/lib/docker|2462000b] -job initserver() = ERR (1)
2014/02/19 12:55:57 initserver: open /var/lib/docker/aufs/layers/cf2414da53f9bcfaa48bc3d58360d7f1cfd3784e4fe51fbef95197709dfc285d: no such file or directory

How do I solve the problem 我该如何解决这个问题?


#1楼

参考:https://stackoom.com/question/1Tlln/Docker无法连接到docker守护程序


#2楼

Do a ps aux | grep docker 做一个ps aux | grep docker ps aux | grep docker to see if the daemon is running. ps aux | grep docker查看守护程序是否正在运行。 If not run /etc/init.d/docker start 如果没有运行/etc/init.d/docker start


#3楼

I had the same problem - “Can’t connect to docker daemon.” 我遇到了同样的问题 - “无法连接到docker守护程序。” (except I didn’t get any ‘file not found’ errors on trying to start the server.) (除了我在尝试启动服务器时没有收到任何’找不到文件’错误。)

‘ps’ showed that “/usr/bin/docker -d” was still running 'ps’显示“/ usr / bin / docker -d”仍在运行

I realised that I’d never actually succeeded in running the server myself though. 我意识到我自己从未真正成功地运行过服务器。 Every attempt had produced 每一次尝试都产生了

...
2014/03/24 21:57:29 pid file found, ensure docker is not running or delete /var/run/docker.pid

So I belatedly realised that installing docker had maybe registered the daemon with upstart, which had started it for me. 所以我姗姗来迟地意识到安装docker可能已经用upstart注册了守护进程,这已经为我启动了它。 Hence, trying to kill the daemon to manually restart it fails (operation not permitted). 因此,尝试终止守护进程以手动重启它失败(操作不允许)。 So I did a 所以我做了一个

sudo kill -9 <PID>

on the daemon process. 在守护进程上。 Another daemon immediately took its place, and this new one DOES now let my CLI client connect: 另一个守护进程立即取而代之,这个新守护进程现在让我的CLI客户端连接:

$ sudo docker info
Containers: 0
Images: 0
Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Dirs: 0
WARNING: No memory limit support
WARNING: No swap limit support

#4楼

I have similar problem. 我有类似的问题。 I had to logout and login again to shell because I have just installed Docker and following command didn’t show in my environment. 我不得不注销并再次登录shell,因为我刚刚安装了Docker,并且我的环境中没有显示以下命令。

export DOCKER_HOST=127.0.0.1:4243 >> ~/.bashrc

#5楼

The best way to find out why Docker isn’t working will be to run the daemon manually. 找出Docker无法正常工作的最佳方法是手动运行守护进程。

$ sudo service docker stop
$ ps aux | grep docker  # do this until you don't see /usr/bin/docker -d
$ /usr/bin/docker -d

The Docker daemon logs to STDOUT, so it will start spitting out whatever it’s doing. Docker守护程序记录到STDOUT,因此它将开始吐出它正在做的任何事情。

Here was what my problem was: 这是我的问题所在:

[8bf47e42.initserver()] Creating pidfile
2015/01/11 15:20:33 pid file found, ensure docker is not running or delete /var/run/docker.pid

This was because the instance had been cloned from another virtual machine. 这是因为该实例已从另一个虚拟机克隆。 I just had to remove the pidfile, and everything worked afterwards. 我只需要删除pid文件,之后一切正常。

Of course, instead of blindly assuming this will work, I’d suggest running the daemon manually one more time and reviewing the log output for any other errors before starting the service back up. 当然,我建议不要盲目地假设这将有效,我建议再次手动运行守护进程,并在启动服务备份之前查看日志输出是否存在任何其他错误。


#6楼

I got the same problem. 我遇到了同样的问题。 In CentOS 6.5: 在CentOS 6.5中:

ps aux |grep `cat /var/run/docker.pid`

If it shows no Docker daemon process exists, then I type: 如果它没有显示存在Docker守护进程,那么我输入:

docker -d

Then Ctrl + D to stop Docker. 然后按Ctrl + D停止Docker。 Because we use the -d option, Docker will run as daemon. 因为我们使用-d选项,所以Docker将作为守护进程运行。 Now we can do: 现在我们可以做到:

service docker start

Then I can do a docker pull centos . 然后我就可以做一个docker pull centos That’s all. 就这样。

NOTE: If these do not work, you can try yum update , and then repeat these again, because I yum install before these. 注意:如果这些不起作用,您可以尝试yum update ,然后重复这些,因为我在这之前yum install

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值