Can't run docker on os X with boot2docker

混江龙づ霸主 提交于 2019-12-11 03:11:27

问题


I've tried to remove docker with this manual.

And I removed virtualbox. And then tried to install boot2docker.

After boot2docker init etc (by the manual on docker site)

docker run helloworld

gives me this error

Cannot connect to the Docker daemon. Is 'docker -d' running on this host?

boot2docker status
running

docker version
Client version: 1.7.0
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 0baf609
OS/Arch (client): darwin/amd64
Cannot connect to the Docker daemon. Is 'docker -d' running on this host?

回答1:


You need to run boot2docker up then docker run helloworld.




回答2:


Boot2docker is not the recommended way of using Docker (on Windows/OS X) anymore (IMHO).

See Docker Machine instead (which can use the "boot2docker iso" internally, but not only).

You may also want to import your existing boot2docker environment (to keep your built images, etc.), it's possible too.

Then using Docker Machine, you can create a working Docker environment with the following commands:

On OS X (or an OS which supports eval and export commands), if you have the Docker CLI installed:

docker-machine create -d virtualbox dev
eval "$(docker-machine env dev)"
docker run hello-world

OR

On any OS, if you have not the Docker CLI installed:

docker-machine create -d virtualbox dev
docker-machine ssh dev
docker run hello-world



回答3:


Maybe the daemon is not running?

Damiens-MacBook-Air:tmp damien$ docker version
Client version: 1.7.0
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 0baf609
OS/Arch (client): darwin/amd64
Cannot connect to the Docker daemon. Is 'docker -d' running on this host?

... check if the daemon is running :

Damiens-MacBook-Air:tmp damien$ boot2docker ssh sudo /etc/init.d/docker status
Docker daemon is not running
error in run: exit status 1

then start it :

Damiens-MacBook-Air:tmp damien$ boot2docker ssh sudo /etc/init.d/docker start
Need TLS certs for boot2docker,127.0.0.1,10.0.2.15,192.168.59.103
-------------------

and now you should be able to connect.

Damiens-MacBook-Air:tmp damien$ docker version
Client version: 1.7.0
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 0baf609
OS/Arch (client): darwin/amd64
Server version: 1.7.0
Server API version: 1.19
Go version (server): go1.4.2
Git commit (server): 0baf609
OS/Arch (server): linux/amd64


来源:https://stackoverflow.com/questions/31157999/cant-run-docker-on-os-x-with-boot2docker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!