I installed boot2docker and I ran:

./boot2docker start
 export DOCKER_HOST=tcp://localhost:4243

I started a tutorial from the Docker site.

I don't understand one thing - when I run:

sudo docker info
Get http:///var/run/docker.sock/v1.11/info: dial unix /var/run/docker.sock: no such file or directory

However when I run without sudo it works:

MacCris:bin cristianc$ docker info
Containers: 2
Images: 10
Storage Driver: aufs
 Root Dir: /mnt/sda1/var/lib/docker/aufs
 Dirs: 14
Execution Driver: native-0.2
Kernel Version: 3.14.1-tinycore64
Debug mode (server): true
Debug mode (client): false

Any idea why running with sudo as in the tutorial does not work (at least for me)?

  • 2
    This is because using sudo is clearing out your env. There is no need to use sudo here because you are connecting over the TCP interface
    – cpuguy83
    Jun 14, 2014 at 13:18

5 Answers 5


The DOCKER_HOST environment variable isn't set. You can confirm this by doing:

> env

Then as sudo:

> sudo env

Without the DOCKER_HOST variable set, docker can't connect to the daemon.



sudo DOCKER_HOST=$DOCKER_HOST docker run

This way the required environment variable will be available with sudo.


If you want the DOCKER_HOST variable from your profile to be available when you run docker command with sudo, then you can add the following line to sudoers file. Open with:

sudo visudo


Defaults        env_keep += "DOCKER_HOST"

If you are using boot2docker, then go to /Application folder and run the command

$(boot2docker shellinit)

It will fix your DOCKER_HOST variable in environment.


Setting the environment variable DOCKER_HOST to tcp:// works for me.

Quickest way would be running this in your command line (for OSX/Unix/Linux machines):

export DOCKER_HOST=tcp://

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.