• Register
0 votes

Problem :

I have installed docker-machine 0.1.0 and docker-compose 1.1.0 on my Mac OS 10.8.5.
My Docker-machine is running normally and it can be connected by docker-machine ssh as follows:

$ docker-machine ls

NAME   ACTIVE   DRIVER       STATE     URL                         SWARM

dev    *        virtualbox   Running   tcp://  

But I am unable to connect from docker-compose.

Getting following error:

$ docker-compose 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.

My Dockerfile and docker-compose.yml are as follows:


FROM centos:centos7




  build: .

Why can't I connect? Any clues?

7.5k points

Please log in or register to answer this question.

2 Answers

0 votes

Solution :

The docker daemon always runs as the root user so you need to write sudo before your Docker command(s).

If you cant use sudo when you use the docker command. Then please create a Unix group called docker and add your users to it. So when the docker daemon starts it will mak the ownership of the Unix socket read or writable by the docker group.

Please follow below steps to create the docker group and add your user to it:

1. Create the docker group by below command.

$ sudo groupadd docker

2. Add your user to the docker group by below command.

$ sudo usermod -aG docker $USER

3. Log out and log back in to it so that your group membership is re-evaluated.

4. Now Verify that you can use the docker commands without the use of sudo by below command.

$ docker run hello-world

This command will download a test image and will run it in a container. When the container runs it prints an informational message and exits.

Further Readings:


38.6k points
0 votes

The Docker machine is running but you need to export some environment to establish the connection with the Docker machine. By default, the Docker CLI client is trying to communicate to the daenon using http+unix://var/run/docker.sock. Export the correct environment variables using eval and then try again. You can also just run docker-machine env dev to see the environment variables it will see.


There are two possible reasons for this error message;

  • The most common reason is that you are running the command as does not have the permission to access docker.
  • The other reason is that you have not started the docker.


Solution for permission denied:

If you don’t have the permission to access docker, then you can fix this either by running the command as root using sudo since the root has permission to access the docker or adding your user to the docker group.

sudo usermod –a –G docker $USER

After this the user has to log out and log back in completely.

Docket not started:

If you don’t have started docker on Ubuntu, then you can start it by using;

sudo systemct1 enable docker # Auto-start on boot

sudo systemct1 start docker #start right now


3.9k points