Docker Error: /var/run/docker.sock: no such file or directory

I'm new to docker. I have a shell script that loads data in impala, and I want a docker file that launches, creates an image and launches the container. I am on a mac, boot2docker is installed, and DOCKER_HOST env is configured.

 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 set 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 there something wrong with my docker installation?

When I do docker pull busybox , it pulls out the image and the 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 

Did I miss something?

+84
docker boot2docker
Aug 18 '14 at 22:04
source share
11 answers

You do not need to run docker commands as sudo when you use boot2docker , since every command passed to boot2docker VM runs as root by default.

You see an error when you work as sudo , because sudo does not have the DOCKER_HOST env set, only your user does.

You can confirm this by doing:

 $ env 

Then a

 $ sudo env 

We are looking for DOCKER_HOST in each output.

As for the docker file that runs your script, there might be something like this 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 create your docker image, which you can see by doing:

 docker images 

Then, to start the container, you can do the following:

 docker run your-image-name:your-tag 

This start command will start the container from the image created with your Dockerfile and your build, and then Dockerfile when script.sh completes.

+85
Aug 18 '14 at 22:25
source share

You can quickly set up your environment with shellinit

At the command prompt, do:

 $(boot2docker shellinit) 

This will populate and export environment variables and initialize other functions.

+45
Nov 07 '14 at 18:43
source share

On my MAC, when I run boot2docker-vm on the terminal using

 boot2docker start 

I see the following

 To connect the Docker client to the Docker daemon, please set: export DOCKER_CERT_PATH= export DOCKER_TLS_VERIFY=1 export DOCKER_HOST=tcp://:2376 

After setting these environment variables, I was able to run the build without any problems.

Update [2016-04-28] If you use the latest versions of dockers, you can do

eval $(docker-machine env) set the environment

( docker-machine env prints export statements)

+25
Nov 01
source share

docker pull will fail if docker service not running. Make sure it is running on

 :~$ ps aux | grep docker root 18745 1.7 0.9 284104 13976 ? Ssl 21:19 0:01 /usr/bin/docker -d 

If it is not running, it can be started using

sudo service docker start

For Ubuntu 15 and above use

sudo systemctl start docker

+23
Apr 09 '15 at 15:54
source share

I also got this error. Although I did not use boot2docker , I just installed a “simple” docker on Ubuntu (see https://docs.docker.com/installation/ubuntulinux/ ).

I got an error ("dial unix / var / run / docker.sock: there is no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?") Because the docker daemon was not working .

In Ubuntu you need to start the service :

 sudo service docker start 

See also http://blog.arungupta.me/resolve-dial-unix-docker-sock-error-techtip64

+16
Mar 28 '15 at 11:42
source share

For boot2docker on Windows, after viewing:

 FATA[0000] Get http:///var/run/docker.sock/v1.18/version: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS? 

All I have done is:

 boot2docker start boot2docker shellinit 

Generated by:

 export DOCKER_CERT_PATH=C:\Users\vonc\.boot2docker\certs\boot2docker-vm export DOCKER_TLS_VERIFY=1 export DOCKER_HOST=tcp://192.168.59.103:2376 

Finally:

 boot2docker ssh 

And the docker is working again

+8
May 26 '15 at 18:35
source share

On Linux, first of all, run sudo service docker start in the terminal.

+6
Jul 19 '15 at
source share

If you are using CentOS 7 and you installed Docker via yum, be sure to run:

 $ sudo systemctl start docker $ sudo systemctl enable docker 

This will start the server and also restart it automatically at boot.

+5
Sep 16 '15 at 18:56
source share

To set up your environment and save it for future sessions, you can:

 echo 'export DOCKER_HOST="tcp://$(boot2docker ip 2>/dev/null):2375";' >> ~/.bashrc 

Then: source ~/.bashrc

And your environment will be set up in every session

+3
Dec 03 '14 at 21:10
source share

The first / var / run / docker.sock refers to the same path in your boot2docker virtual machine. Write correctly for windows / var / run / docker.sock

0
Dec 19 '16 at 5:44
source share

You may not be an OP, but someone may have a directory named /var/run/docker.sock/ due to how many times you hack and cross so that everything is ok with the docker (especially noobs) . Delete this directory and try again.

It helped me along the way to get it working on Centos 7.

0
Jan 13 '17 at 13:13
source share



All Articles