12

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)?

migrated from serverfault.com May 31 '14 at 1:32

This question came from our site for system and network administrators.

  • 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 '14 at 13:18
15

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.

3

Try:

sudo DOCKER_HOST=$DOCKER_HOST docker run

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

2

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

Add:

Defaults        env_keep += "DOCKER_HOST"
1

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.

0

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

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

export DOCKER_HOST=tcp://192.168.59.103:2375

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.