Compose: Fig can't connect to DOCKER_HOST=tcp://

Created on 10 Feb 2014  路  54Comments  路  Source: docker/compose

On OS X with boot2docker 0.5.4:

$ docker version
Client version: 0.8.0
Go version (client): go1.2
Git commit (client): cc3a8c8
Server version: 0.8.0
Git commit (server): cc3a8c8
Go version (server): go1.2
$ ~/bin/boot2docker up
[2014-02-10 21:58:12] boot2docker-vm is already running.
$ echo $DOCKER_HOST
tcp://
$ fig --version
fig 0.2.1
$ fig up
Couldn't connect to Docker daemon at http:/ - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

docker build . worked fine for me, but fig seems unable to handle the tcp:// URL.

Most helpful comment

@gregory
Found the solution.

1) Change the DOCKER_OPTS in /etc/default/docker to:
DOCKER_OPTS="-H tcp://127.0.0.1:4243 -H unix:///var/run/docker.sock"

2) Restart docker
sudo restart docker

3) Make sure that docker is running on localhost:4243 
$ netstat -ant  |grep 4243
tcp        0      0 127.0.0.1:4243          0.0.0.0:*               LISTEN

4) Set DOCKER_HOST (.bashrc)
export DOCKER_HOST=tcp://localhost:4243

$ echo $DOCKER_HOST
tcp://localhost:4243 

5) And now
$ fig run web rails new . --force --database=postgresql --skip-bundle

NOTE, I have:

Ubuntu 14.04
Docker version 1.1.2, build d84a070
Fig 0.5.2

Thanks to http://serverascode.com/2014/05/25/docker-shipyard-multihost.html

All 54 comments

Yeah, we need to fall back to localhost and 4243 as appropriate when the host and/or port isn't specified. For now, setting DOCKER_HOST=tcp://localhost:4243 should fix it.

Great, this works, thanks!

$ docker version
Client version: 1.1.1
Client API version: 1.13
Go version (client): go1.2.1
Git commit (client): bd609d2
Server version: 1.1.1
Server API version: 1.13
Go version (server): go1.2.1
Git commit (server): bd609d2

$ ~/bin/boot2docker status
running
$ echo $DOCKER_HOST
tcp://192.168.59.103:2375
$ fig --version
fig 0.5.1
$ fig up
Couldn't connect to Docker daemon at http+unix://var/run/docker.sock - is it running?
If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

Anyone experiencing the same issue?

@gregory yeah, I got same on:

Ubuntu 14.04
Docker version 1.1.2, build d84a070
Fig 0.5.2

Still not found the way to fix it.
Added detailed explanation here https://github.com/orchardup/fig/issues/73

@gregory
Found the solution.

1) Change the DOCKER_OPTS in /etc/default/docker to:
DOCKER_OPTS="-H tcp://127.0.0.1:4243 -H unix:///var/run/docker.sock"

2) Restart docker
sudo restart docker

3) Make sure that docker is running on localhost:4243 
$ netstat -ant  |grep 4243
tcp        0      0 127.0.0.1:4243          0.0.0.0:*               LISTEN

4) Set DOCKER_HOST (.bashrc)
export DOCKER_HOST=tcp://localhost:4243

$ echo $DOCKER_HOST
tcp://localhost:4243 

5) And now
$ fig run web rails new . --force --database=postgresql --skip-bundle

NOTE, I have:

Ubuntu 14.04
Docker version 1.1.2, build d84a070
Fig 0.5.2

Thanks to http://serverascode.com/2014/05/25/docker-shipyard-multihost.html

Thanks, Got the same issue, and fixed by this thread

@RuslanHamidullin - Thanks for the solution, it works for me even on ubuntu 12.04

@jaydattdesai :beers:

@RuslanHamidullin your solution works for me as well, Thank you.

I have

Ubuntu 14.04
Docker 1.3.2
fig 1.0.1

@trkrameshkumar :beers:

@RuslanHamidullin but every time i log out or restart my laptop, i have to follow these steps again

2) Restart docker
sudo restart docker

3) Make sure that docker is running on localhost:4243 
$ netstat -ant  |grep 4243
tcp        0      0 127.0.0.1:4243          0.0.0.0:*               LISTEN

4) Set DOCKER_HOST (.bashrc)
export DOCKER_HOST=tcp://localhost:4243

$ echo $DOCKER_HOST
tcp://localhost:4243 

how can we make this configuration permanent.

i added this line

export DOCKER_HOST=tcp://localhost:4243
on .bashrc file now it is loaded very time

@trkrameshkumar nice catch :+1:

Hey folks, I just found that doing fig up without sudo resulted in this message whereas sudo fig up did the job. Just wanted to mention to eventually save some of you some head-scratching..

Executing fig commands with sudo seems fix these kinds of issues. In the docker.io blog I also see that people are executing fig as root (http://blog.docker.com/2014/08/orchestrating-docker-containers-in-production-using-fig/).

Are root permissions required or is there any way to use docker/fig at the user level?

sudo chmod 666 /var/run/docker.sock

should help (Ubuntu 14.04)

@evilfrog works for me!

But you have to execute it every time you restart docker.

@ddliu @evilfrog that's a serious security issue; Anyone that is able to access docker.sock has effectively _root_ access to your machine.

@thaJeztah I understand the risk, it's OK for me as a quick fix for my development environment.

@ddliu Alright, just mentioning because posting such things on the internet _will_ result in people doing this blindly.

Having said that, a better approach is described in the documentation;
https://docs.docker.com/installation/ubuntulinux/#giving-non-root-access

Of course, the same applies here; anyone that's able to connect to docker.sock is able to get root access on your machine.

@thaJeztah Agree, risks should be declared.

Docker version is

Docker version 1.0.1, build 990021a

if I run netstat -ant |grep 4243 the result is empty (but docker is running).

Because of this I got same error:

Couldn't connect to Docker daemon at http+unix://var/run/docker.sock - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

Apparently the error is due to the docker daemon that stops as soon as it is started.
Using dmesg, the following messages I found:

[82051.692455] init: docker.io main process ended, respawning
[82051.803605] init: docker.io main process (6945) terminated with status 1
[82051.803615] init: docker.io respawning too fast, stopped

Apparently the issue is due to Linux Mint. Here where they talk about it.

Solved running sudo apt-get install apparmor as described here.

Please help! I am getting the same error again and again whenever i run any docker command!

hassan@hassanmehmood:~$ sudo docker version Client version: 1.0.1 Client API version: 1.12 Go version (client): go1.2.1 Git commit (client): 990021a 2015/03/03 11:12:49 Cannot connect to the Docker daemon. Is 'docker -d' running on this host?```

I tried everything in this thread. Still no luck.

rept@temponia:~/passenger$ netstat -ant  |grep 4243
tcp        0      0 127.0.0.1:4243          0.0.0.0:*               LISTEN     
rept@temponia:~/passenger$ echo $DOCKER_HOST
tcp://localhost:4243
rept@temponia:~/passenger$ sudo docker-compose build
db uses an image, skipping
Building web...
Couldn't connect to Docker daemon at http+unix://var/run/docker.sock - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

This is the version:

rept@temponia:~/passenger$ sudo docker version
Client version: 1.0.1
Client API version: 1.12
Go version (client): go1.2.1
Git commit (client): 990021a
Server version: 1.0.1
Server API version: 1.12
Go version (server): go1.2.1
Git commit (server): 990021a

Any ideas?

Same issue.

vagrant@local:~/template$ docker-compose build
Building web...
Couldn't connect to Docker daemon at http+unix://var/run/docker.sock - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
vagrant@local:~/template$ DOCKER_HOST="unix://var/run/docker.sock" docker-compose build
Building web...
Couldn't connect to Docker daemon at http+unix://var/run/docker.sock - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
vagrant@local:~/template$ sudo docker version
Client version: 1.5.0
Client API version: 1.17
Go version (client): go1.4.1
Git commit (client): a8a31ef
OS/Arch (client): linux/amd64
Server version: 1.5.0
Server API version: 1.17
Go version (server): go1.4.1
Git commit (server): a8a31ef

This helped me:
If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:

sudo usermod -aG docker your-user

Remember that you will have to log out and back in for this to take effect!

Got the problem, and the small fix by @evilfrog solved it on Ubuntu 14.04. Thanks.

I had this problem too after a system crash in Ubuntu 14.04. It turned out my network was not enabled.

I have this issue with docker-compose

$ lsb_release -ds
Debian GNU/Linux 8.1 (jessie)

$ docker -v
Docker version 1.6.2, build 7c8fca2

$ docker-compose -v
docker-compose version: 1.4.0

$ echo $DOCKER_HOST
tcp://localhost:4243

$ netstat -ant | grep 4243
[nothing]

$ sudo service docker status
[...]active (running)[...]

$ docker-compose build
Couldn't connect to Docker daemon at http://localhost:4243 - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment
variable.

docker 1.6.2 is quite old now; also, the standard ports for docker are now 2375 (non-TLS) and 2376 (TLS). Are you sure the daemon is configured to listen on localhost, and on port 4243?

What does docker info and docker version (not -v) output?

I just installed Docker & docker-compose (following the official instructions for Debian 8) along with a brand new Debian installation.

$ docker info
FATA[0000] Cannot connect to the Docker daemon. Is 'docker -d' running on this host? 
$ docker version
Client version: 1.6.2
Client API version: 1.18
Go version (client): go1.3.3
Git commit (client): 7c8fca2
OS/Arch (client): linux/amd64
FATA[0000] Cannot connect to the Docker daemon. Is 'docker -d' running on this host? 

Maybe I should install the curl version ?

Like the error message says, is the daemon running? (ps aux | grep docker)

I don't see it in the processes

$ ps aux | grep docker
me       3644  0.0  0.0  12720  2164 pts/0    S+   16:58   0:00 grep docker

But the service claims to be running

$ sudo service docker status
[...]active (running)[...]

If I run it manually (as root, I'm in the docker group but I'm still getting permission denied), I see no error and it's not exited

$ sudo docker -d
INFO[0000] +job init_networkdriver()                    
INFO[0000] +job serveapi(unix:///var/run/docker.sock)   
INFO[0000] Listening for HTTP on unix (/var/run/docker.sock) 
INFO[0000] -job init_networkdriver() = OK (0)           
WARN[0000] mountpoint for memory not found              
INFO[0000] Loading containers: start.                   

INFO[0000] Loading containers: done.                    
INFO[0000] docker daemon: 1.6.2 7c8fca2; execdriver: native-0.2; graphdriver: aufs 
INFO[0000] +job acceptconnections()                     
INFO[0000] -job acceptconnections() = OK (0)            
INFO[0000] Daemon has completed initialization          

But docker-compose still tells it can't connect to the daemon

just installed Docker & docker-compose (following the official instructions for Debian 8) along with a brand new Debian installation.

Hm, good point; looking at those, the installation docs are not really consistent; for the Debian docs, we're explaining how to install the packages maintained by Debian, whereas for the Ubuntu, RHEL, CentOS and Fedora docs, we explain how to install the packages maintained by _Docker_. I'll open an issue in the Docker issue tracker, because I think we should be consistent (or at least explain both options)

Back to the issue at hand here; so, it looks like the daemon (as installed from the Debian packages), fails to start properly. Installing the Docker maintained version could work; the easiest way to do this is;

curl -sSL https://get.docker.com/ | sh

(be sure to uninstall the docker.io package first).

Before doing that, it would be interesting to check _why_ it fails to start; could you:

I'll "ping" the maintainers of the Debian docker.io package, perhaps they have some thoughts;

ping @tianon @paultag I think you may be interested in this one, or are able to assist here

That http://localhost:4243 looks fishy -- why wouldn't you be using the unix socket?

Thank you very much @thaJeztah, I'll be able to check all these things tomorrow:

  • Checking the Docker log
  • Checking the config with the script
  • Uninstall docker.io
  • Install docker with the curl script

I agree about the installation instructions, maybe there should be only 1 suggested installation, I saw the curl install but I though the Debian one was more appropriate

I found some logs in /var/log/daemon.log (no other log file found):

level=info msg="+job init_networkdriver()"
level=info msg="+job serveapi(fd://)"
level=info msg="Listening for HTTP on fd ()"
level=info msg="-job init_networkdriver() = OK (0)"
level=warning msg="mountpoint for memory not found"
level=info msg="Loading containers: start."
level=info msg="Loading containers: done."
level=info msg="docker daemon: 1.6.2 7c8fca2; execdriver: native-0.2; graphdriver: aufs"
level=info msg="+job acceptconnections()"
level=info msg="-job acceptconnections() = OK (0)"
level=info msg="Daemon has completed initialization"

Actually exactly the same I'm getting with docker -d (which seems logical) so the service seems successfully loaded, maybe it's using the socket instead (like @tianon was saying)

$ ./check-config.sh # (from docker github)

warning: /proc/config.gz does not exist, searching other paths for kernel config ...
info: reading kernel config from /boot/config-3.16.0-4-amd64 ...

Generally Necessary:

  • cgroup hierarchy: properly mounted [/sys/fs/cgroup]
  • CONFIG_NAMESPACES: enabled
  • CONFIG_NET_NS: enabled
  • CONFIG_PID_NS: enabled
  • CONFIG_IPC_NS: enabled
  • CONFIG_UTS_NS: enabled
  • CONFIG_DEVPTS_MULTIPLE_INSTANCES: enabled
  • CONFIG_CGROUPS: enabled
  • CONFIG_CGROUP_CPUACCT: enabled
  • CONFIG_CGROUP_DEVICE: enabled
  • CONFIG_CGROUP_FREEZER: enabled
  • CONFIG_CGROUP_SCHED: enabled
  • CONFIG_CPUSETS: enabled
  • CONFIG_MEMCG: enabled
  • CONFIG_MACVLAN: enabled (as module)
  • CONFIG_VETH: enabled (as module)
  • CONFIG_BRIDGE: enabled (as module)
  • CONFIG_BRIDGE_NETFILTER: enabled
  • CONFIG_NF_NAT_IPV4: enabled (as module)
  • CONFIG_IP_NF_FILTER: enabled (as module)
  • CONFIG_IP_NF_TARGET_MASQUERADE: enabled (as module)
  • CONFIG_NETFILTER_XT_MATCH_ADDRTYPE: enabled (as module)
  • CONFIG_NETFILTER_XT_MATCH_CONNTRACK: enabled (as module)
  • CONFIG_NF_NAT: enabled (as module)
  • CONFIG_NF_NAT_NEEDED: enabled
  • CONFIG_POSIX_MQUEUE: enabled

Optional Features:

  • CONFIG_MEMCG_KMEM: missing
  • CONFIG_MEMCG_SWAP: enabled
  • CONFIG_MEMCG_SWAP_ENABLED: missing
    _(note that cgroup swap accounting is not enabled in your kernel config, you can enable it by setting boot option "swapaccount=1")_
  • CONFIG_RESOURCE_COUNTERS: enabled
  • CONFIG_BLK_CGROUP: enabled
  • CONFIG_IOSCHED_CFQ: enabled
  • CONFIG_BLK_DEV_THROTTLING: enabled
  • CONFIG_CGROUP_PERF: enabled
  • CONFIG_CGROUP_HUGETLB: missing
  • CONFIG_NET_CLS_CGROUP: enabled (as module)
  • CONFIG_CGROUP_NET_PRIO: enabled
  • CONFIG_CFS_BANDWIDTH: missing
  • CONFIG_FAIR_GROUP_SCHED: enabled
  • CONFIG_RT_GROUP_SCHED: missing
  • CONFIG_EXT3_FS: missing
  • CONFIG_EXT3_FS_XATTR: missing
  • CONFIG_EXT3_FS_POSIX_ACL: missing
  • CONFIG_EXT3_FS_SECURITY: missing
    _(enable these ext3 configs if you are using ext3 as backing filesystem)_
  • CONFIG_EXT4_FS: enabled (as module)
  • CONFIG_EXT4_FS_POSIX_ACL: enabled
  • CONFIG_EXT4_FS_SECURITY: enabled
  • Storage Drivers:

    • "aufs":

    • CONFIG_AUFS_FS: enabled (as module)

    • "btrfs":

    • CONFIG_BTRFS_FS: enabled (as module)

    • "devicemapper":

    • CONFIG_BLK_DEV_DM: enabled (as module)

    • CONFIG_DM_THIN_PROVISIONING: enabled (as module)

    • "overlay":

    • CONFIG_OVERLAY_FS: missing

    • "zfs":

    • /dev/zfs: missing

    • zfs command: missing

    • zpool command: missing

Still have the issue after uninstalling docker.io and installed with the curl way (now 1.8.1):

$ echo $DOCKER_HOST
tcp://localhost:4243
$ docker-compose ps
Couldn't connect to Docker daemon at http://localhost:4243 - is it running?

If it's at a non-standard location,
specify the URL with the DOCKER_HOST environment variable.

Fixed !
Systemd docker installation seems to use the systemd socket (fd://) by default.
Trying to use it, docker-compose tells me the fd protocol is not implemented.
So I added the /var/run/docker.sock to the systemd docker conf and I've been able to connect.

Good to hear! Just a tip; when customizing systemd options, the best approach is to _not_ modify the default docker.service, but to use "drop-ins"; this section explains how to do that; https://docs.docker.com/articles/systemd/#custom-docker-daemon-options

I still wonder where the DOCKER_HOST localhost:4234 came from (since you mentioned this was on a fresh install).

@dnephin is there anything to be done in docker-compose w.r.t not supporting fd://?

Thank you for the systemd option tip.
To be clear about localhost:4234, I did set this environment variable because the default http+unix://var/run/docker.sock assumed by docker-compose were not connecting (and I though the daemon were defaulting to localhost:4234).

@Glideh ah, thanks for explaining, yes 4234 was the "old" port, we now have 2375/2376 registered at iana.

I see, keeping in mind the default was actually fd://

@Glideh yes, perhaps a separate issue should be created for that?

That's right, let me create one

I had the following error:

$ docker-compose up
Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

Following mucsi96's piece of advice (https://github.com/docker/compose/issues/88#issuecomment-105768504), I added myself to the docker group and now docker-compose works fine.

@WinstonSureChill glad, had the same problem and the same solution as yours. Thanks

@WinstonSureChill same problem but adding myself to docker group did not solve :-(

~/l/l/docker-symfony> groups                                                                                                                                  
    lrkwz adm cdrom sudo dip plugdev lpadmin sambashare wireshark docker

@lrkwz I had the same issue - turned out it was due to a corrupted container as described in https://github.com/docker/docker/issues/17688

The problem is on Your docker instalation. I got the same isue here for awhile.
Just add your user to docker group, and try to run docker version, you shuld get something like this:

Client:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.2
 Git commit:   a34a1d5
 Built:        Fri Nov 20 13:20:08 UTC 2015
 OS/Arch:      linux/amd64

Server:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.2
 Git commit:   a34a1d5
 Built:        Fri Nov 20 13:20:08 UTC 2015
 OS/Arch:      linux/amd64

But if you got some instalation issue you won't be able to see server info.
You can always run with root user sudo docker-compose up.
I hope that helps.

I had the same error, after 15 min of debugging. Turns out all it needs is a sudo :)
Check out [Create a Docker group] here https://docs.docker.com/engine/installation/linux/ubuntulinux/ to get rid of the sudo prefix.

@rusllonrails thank you mate

Was this page helpful?
0 / 5 - 0 ratings