无法在Ubuntu Windows上的bash上连接到Docker守护程序 [英] Cannot connect to the Docker daemon on bash on Ubuntu windows

查看:104
本文介绍了无法在Ubuntu Windows上的bash上连接到Docker守护程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够安装docker,docker-compose和docker-machine

I am able to install docker, docker-compose and docker-machine

但是,当我尝试运行时

root@DESKTOP-51NFMIM:~# docker ps
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

是否有解决此问题的建议?

Is there any suggestion for solving this problem?

推荐答案

在此信息上找到了解决方案: https://blog.jayway.com/2017/04/19/running-docker-on-bash-on-windows/

Found the solution on this post: https://blog.jayway.com/2017/04/19/running-docker-on-bash-on-windows/

在另一台机器上的引擎上运行docker实际上非常容易,因为Docker可以公开CLI可以附加到的TCP端点。

Running docker against an engine on a different machine is actually quite easy, as Docker can expose a TCP endpoint which the CLI can attach to.

默认情况下,此TCP终结点处于关闭状态。要激活它,请右键单击任务栏中的Docker图标,然后选择设置,然后选中在不带TLS的tcp:// localhost:2375上公开守护程序旁边的框。

This TCP endpoint is turned off by default; to activate it, right-click the Docker icon in your taskbar and choose Settings, and tick the box next to "Expose daemon on tcp://localhost:2375 without TLS".

完成后,我们需要做的就是指示Bash下的CLI连接到Windows下运行的引擎,而不是连接到Bash下运行的不存在的引擎,就像这样:

With that done, all we need to do is instruct the CLI under Bash to connect to the engine running under Windows instead of to the non-existing engine running under Bash, like this:

$ docker -H tcp://0.0.0.0:2375 images

有两种方法可以使其永久化–为上述命令添加别名或导出一个环境变量,该变量指示Docker在哪里找到主机引擎(注意:请确保在下面使用单撇号) :

There are two ways to make this permanent – either add an alias for the above command or export an environment variable which instructs Docker where to find the host engine (NOTE: make sure to use single apostrophe's below):

$ echo "export DOCKER_HOST='tcp://0.0.0.0:2375'" >> ~/.bashrc
$ source ~/.bashrc

现在,从Bash运行docker命令

Now, running docker commands from Bash works just like they’re supposed to.

$ docker run hello-world

成功的响应:

Hello from Docker!This message shows that your installation appears to be working correctly.

这篇关于无法在Ubuntu Windows上的bash上连接到Docker守护程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆