• Register
0 votes
406 views

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://192.168.99.100:2376  

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:

Dockerfile

FROM centos:centos7

DOCKER_HOST tcp://192.168.99.100:2376

docker-compose.yml

web:

  build: .

Why can't I connect? Any clues?

7.5k points

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:

https://docs.docker.com/install/linux/linux-postinstall/

36.1k 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.

Reasons:

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.

Solutions:

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

Related questions

0 votes
1 answer 221 views
221 views
Problem : I installed the docker-machine 0.1.0 and docker-compose 1.1.0 on the Mac OS 10.8.5. Docker-machine is running normally and able to connect by the docker-machine ssh. But can't connect from docker-compose getting following error: $ docker-compose up ... running? If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable. Why can't I connect? Any clues?
asked Jan 20 jwilliam 3.9k points
1 vote
1 answer 49 views
49 views
Problem : Facing the weird following issue cannot connect to the docker daemon at unix:///var/run/docker.sock. is the docker daemon running?
asked Nov 8, 2019 peterlaw 6.9k points
1 vote
1 answer 24 views
24 views
Problem : Encountered bellow docker error cannot connect to the docker daemon at unix:///var/run/docker.sock. is the docker daemon running?
asked Nov 8, 2019 peterlaw 6.9k points
0 votes
1 answer 47 views
47 views
Problem : After I tried to update my Docker version to 0.8.0, I face an error message while I try to enter sudo docker version as below : Client version: 0.8.0 Go version (client): go1.2 Git commit (client): cc3a8c8 2020 ... 12:55:57 initserver: open /var/lib/docker/aufs/layers/cf2414da53f9bcfaa48bc3d58360d7f1cfd3784e4fe51fbef95197709dfc285d: no such file or directory How can I resolve the issue?
asked Jan 3 alecxe 7.5k points
1 vote
1 answer 122 views
122 views
Problem : Currently I am learning Docker. Recently I came across below Docker error in one of the projects: “Invalid reference format: repository name must be lowercase” I am trying to understand the causes of this message and way to fix above error message. Can someone guide me in solving above error message?
asked Mar 28 morrisBson 3.2k points