我是靠谱客的博主 等待乌龟,最近开发中收集的这篇文章主要介绍mac上用docker,不需要加sudo,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

mac上装完boot2docker之后,想测试一下docker,结果书上的例子出错:

$ sudo docker run hello-world           

Post http:///var/run/docker.sock/v1.19/containers/create: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?

解决办法:不要加sudo

$ docker run hello-world 


Hello from Docker.

This message shows that your installation appears to be working correctly.

...

原因如下:

When you use boot2docker, the docker daemon is running in a VM, essentially on a different machine. To communicate with a docker daemon on another machine, you must use the TLS connection (over HTTPS to the daemon's REST API). That's why you had to set up DOCKER_HOST and DOCKER_CERT_PATH. Since the daemon is running on a different machine, you don't need to be root to communicate with it because outgoing http connections don't require root, unlike trying to talk with the unix:///var/run/docker.sock socket.

But when you run sudo docker, suddenly you're a different user, you're root. The environment variables you set as your regular account are not set. So the docker CLI uses its default communication method: the unix socket. The socket isn't there, because the daemon is running on a different machine (the boot2docker vm). Hence the error message.


原文地址:

http://stackoverflow.com/questions/27558496/installing-a-web-application-in-a-docker-container-dial-unix-var-run-docker-so

最后

以上就是等待乌龟为你收集整理的mac上用docker,不需要加sudo的全部内容,希望文章能够帮你解决mac上用docker,不需要加sudo所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(40)

评论列表共有 0 条评论

立即
投稿
返回
顶部