当我把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?
我按照说明,输入命令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
我怎么解决这个问题?
经过详细的调查,这个问题似乎每次在Mac OS X重新启动(或Docker虚拟机重新启动)后都会发生,这会阻止Docker客户端连接到Docker守护进程。
要解决这个问题,你可以:
A)使用官方安装程序(https://www.docker.com/products/docker-toolbox)重新安装Docker工具箱,或者简单地
B)依次执行以下命令:
# First make sure that the virtual machine is running
docker-machine start default
# Regenerate TLS connection certs, requires confirmation
docker-machine regenerate-certs default
# Finally, set env
eval "$(docker-machine env default)"
C)和(B)一样,你也可以复制粘贴下面这行来运行所有三个命令:
docker-machine start default; docker-machine regenerate-certs default; eval "$(docker-machine env default)"
如果你得到以下错误:
Error getting SSH command: Something went wrong running an SSH command!
command : cat /etc/os-release
err : exit status 255
output :
只要再次重新运行这三个命令,第二次就可以工作了。
检查你是否正在使用Docker Machine:)
运行docker-machine env default就可以了。
因为根据文档:
Docker Machine is a tool that lets you install Docker Engine on
virtual hosts, and manage the hosts with docker-machine commands. You
can use Machine to create Docker hosts on your local Mac or Windows
box, on your company network, in your data center, or on cloud
providers like AWS or Digital Ocean.
Using docker-machine commands, you can start, inspect, stop, and
restart a managed host, upgrade the Docker client and daemon, and
configure a Docker client to talk to your host.
Point the Machine CLI at a running, managed host, and you can run
docker commands directly on that host. For example, run
docker-machine env default to point to a host called default, follow on-screen
instructions to complete env setup, and run docker ps,
docker run hello-world, and so forth.
https://docs.docker.com/machine/overview/