docker错误:/var/run/docker.sock:没有这样的文件或目录 [英] docker error: /var/run/docker.sock: no such file or directory

查看:935
本文介绍了docker错误:/var/run/docker.sock:没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是码头工人的新人我有一个shell脚本将数据加载到impala中,我想要一个运行的Docker文件构建一个映像并运行该容器。
我在mac上,安装了boot2docker,并且设置了 DOCKER_HOST env。

  bash-3.2 $ docker info 
容器:0
图像:0
存储驱动程序:aufs
根目录:/ mnt / sda1 / var / lib / docker / aufs
Dirs:0
执行驱动程序:native-0.2
内核版本:3.15.3-tinycore64
调试模式(服务器):true
调试模式客户端):false
Fds:10
Goroutines:10
事件监听器:0
初始路径:/ usr / local / bin / docker
套接字:[unix:/ //var/run/docker.sock tcp://0.0.0.0:2375]

我是尝试只是使用以下方式安装了一个预构建的映像:

  sudo docker pull busybox 

我收到此错误:



sudo docker pull busybox
2014/08/18 17:56:19发布http:///var/run/docker.sock/images/create?fromImage = busybox& tag =:dial unix /var/run/docker.sock:no such文件或目录



有问题我的码头设置?



当我做一个 docker pull busybox 时,它会提取图像并下载完成。

  bash-3.2 $ docker pull busybox 
拉出存储库busybox
a9eb17255234:下载完成
fd5373b3d938:下载完成
d200959a3e91:下载完成
37fca75d01ff:下载完成
511136ea3c5a:下载完成
42eed7f1bf2a:下载完成
c120b7cab0b0:下载完成
f06b02872d52:下载完成
120e218dd395:下载完成
1f5049b3536e:下载完成
bash-3.2 $ docker运行busybox / bin / echo你好医生
你好医生

我错过了什么?

解决方案

您不需要当您使用 boot2docker 作为每个命令传递到 sudo > boot2docker 默认情况下,VM以root身份运行。



你看到呃当您以 sudo 运行时,因为 sudo 没有 DOCKER_HOST env set,只有您的用户可以。



您可以通过执行以下操作来确认:

  $ env 

然后一个

  $ sudo env 

在每个输出中寻找 DOCKER_HOST



至于有一个运行你的脚本的docker文件,为您工作:



Dockerfile

  FROM busybox 

#将您的脚本复制到docker image
ADD /path/to/your/script.sh /usr/local/bin/script.sh

#运行脚本
CMD /usr/local/bin/script.sh

然后你可以运行:

  docker build -t your-image-name:your-tag。 

这将构建您的码头图像,您可以通过执行以下操作查看:

  docker image 

然后运行您的容器,您可以执行以下操作:

  docker运行your-image-name:your-tag 

此运行命令将从您使用 Dockerfile 和你的构建命令,然后一旦你的 script.sh 完成执行,它就会完成。


I am new to docker. I have a shell script that loads data into impala and I want a docker file that runs builds an image and run the container. I am on mac, installed boot2docker and have the DOCKER_HOST env set up.

bash-3.2$ docker info
Containers: 0
Images: 0
Storage Driver: aufs
Root Dir: /mnt/sda1/var/lib/docker/aufs
Dirs: 0
Execution Driver: native-0.2
Kernel Version: 3.15.3-tinycore64
Debug mode (server): true
Debug mode (client): false
Fds: 10
Goroutines: 10
EventsListeners: 0
Init Path: /usr/local/bin/docker
Sockets: [unix:///var/run/docker.sock tcp://0.0.0.0:2375]

I am trying to just installed a pre-built image using:

sudo docker pull busybox

I get this error:

sudo docker pull busybox 2014/08/18 17:56:19 Post http:///var/run/docker.sock/images/create?fromImage=busybox&tag=: dial unix /var/run/docker.sock: no such file or directory

Is something wrong with my docker setup?

When I do a docker pull busybox, It pulls the image and download is complete.

bash-3.2$ docker pull busybox
Pulling repository busybox
a9eb17255234: Download complete 
fd5373b3d938: Download complete 
d200959a3e91: Download complete 
37fca75d01ff: Download complete 
511136ea3c5a: Download complete 
42eed7f1bf2a: Download complete 
c120b7cab0b0: Download complete 
f06b02872d52: Download complete 
120e218dd395: Download complete 
1f5049b3536e: Download complete 
bash-3.2$ docker run busybox /bin/echo Hello Doctor
Hello Doctor

Am I missing something?

解决方案

You don't need to run any docker commands as sudo when you're using boot2docker as every command passed into the boot2docker VM runs as root by default.

You're seeing the error when you're running as sudo because sudo doesn't have the DOCKER_HOST env set, only your user does.

You can confirm this by doing a:

$ env

Then a

$ sudo env

And looking for DOCKER_HOST in each output.

As for having a docker file that runs your script, something like this might work for you:

Dockerfile

FROM busybox

# Copy your script into the docker image
ADD /path/to/your/script.sh /usr/local/bin/script.sh

# Run your script
CMD /usr/local/bin/script.sh

Then you can run:

docker build -t your-image-name:your-tag .

This will build your docker image, which you can see by doing a:

docker images

Then, to run your container, you can do a:

docker run your-image-name:your-tag

This run command will start a container from the image you created with your Dockerfile and your build command and then it will finish once your script.sh has finished executing.

这篇关于docker错误:/var/run/docker.sock:没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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