Reputation: 3132
I am getting error on ubuntu 16.04
"ERROR: Couldn't connect to Docker daemon - you might need to run
docker- machine start default
. "
when i run following command
sudo docker-compose up
Can any one answer ?
Upvotes: 67
Views: 121773
Reputation: 11
For me the problem was that my VM at some moment began to run on port 2376 instead of the default 2375... Thus since that happened I run any docker commands with the parameter "-H 192.168.99.100:2376", and "docker-compose up" as well
Upvotes: 0
Reputation: 984
If you installed docker from the snap store , you can start docker this way
sudo snap start docker
and then try this :
sudo docker-compose up
Upvotes: 0
Reputation: 1285
You don't need to think much. Run the command with sudo previlage.
sudo docker-compose up -d --build
Upvotes: 10
Reputation: 18206
I had this error and did the unthinkable: I just rebooted my laptop. I was and am annoyed about it, but it took about 1 minute and it worked.
Upvotes: 0
Reputation: 849
Use "sudo" privilege as prefix in all of your 'docker-compose' terminal commands.
Upvotes: 2
Reputation: 988
If you are on Windows 10 and using Docker Toolbox use this
& "C:\Program Files\Docker Toolbox\docker-machine.exe" env | Invoke-Expression
Upvotes: 0
Reputation: 8419
After
#sudo snap remove docker //only if required
sudo snap install docker
Following command worked for me
docker-compose --verbose up -d
In case docker service is not active, please do any of the following (give priority to first one)
1. sudo snap start docker
2. sudo systemctl start docker
3 .sudo service docker start
Upvotes: 6
Reputation: 1208
I was also facing this
asif@ck ~/u/m/moberry_pizza_order (main)> docker-compose -f local.yml build
ERROR: Couldn't connect to Docker daemon - you might need to run `docker-machine start default`.
asif@ck ~/u/m/moberry_pizza_order (main) [1]> docker-machine start default
Docker machine "default" does not exist. Use "docker-machine ls" to list machines. Use "docker-machine create" to add a new one.
asif@ck ~/u/m/moberry_pizza_order (main) [1]> docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
asif@ck ~/u/m/moberry_pizza_order (main)> docker-machine create -d dev;
Driver "dev" not found. Do you have the plugin binary "docker-machine-driver-dev" accessible in your PATH?
asif@ck ~/u/m/moberry_pizza_order (main) [1]> docker-compose -f local.yml up
ERROR: Couldn't connect to Docker daemon - you might need to run `docker-machine start default`.
Then I tried following,
$ sudo apt update && sudo apt dist-upgrade
$ docker-compose --version
docker-compose version 1.25.5, build unknown
$ sudo usermod -aG docker $USER
$ newgrp docker
$ docker run hello-world
Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world b8dfde127a29: Pull complete Digest: sha256:f2266cbfc127c960fd30e76b7c792dc23b588c0db76233517e1891a4e357d519 Status: Downloaded newer image for hello-world:latest
Hello from Docker! This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
After doing those my command start working
$docker-compose -f local.yml up
Creating network "moberry_pizza_order_default" with the default driver Creating volume "moberry_pizza_order_local_postgres_data" with default driver Creating volume "moberry_pizza_order_local_postgres_data_backups" with default driver Building postgres Step 1/4 : FROM postgres:13.2 13.2: Pulling from library/postgres
So restarting the daemon is the main thing here. you can do it several ways.
Upvotes: 1
Reputation: 116
Running $sudo docker compose up -d resolved my issue. Actually mine is permissions issue which I came to know by providing verbose option.
Upvotes: 5
Reputation: 1572
I had this same error 10 minutes ago and solved it by doing:
sudo snap remove docker
when finished:
sudo snap install docker
Problem solved.
Upvotes: 2
Reputation: 6232
My issue was that I was missing $ sign in front of variable in the image name
image: imagename:{TAG:-develop-latest}
Upvotes: 0
Reputation: 87
Sometimes, this error appears if you built stack before. Reason of giving error is migh be file permissions. If in building process docker generates new files or edits some files, there will be some root owned files.
So, if the reason is permissions, make your user the owner of all application files.
$ sudo chown -R ${USER} .
Upvotes: 2
Reputation: 2813
If you installed Docker as a snap
package try this:
sudo snap start docker
Upvotes: 33
Reputation: 142
After installing can execute command to have access to docker functionality without sudo. In my sitation, with same errors all is resolved after :
$ sudo usermod -aG docker ${USER}
$ su - ${USER}
$ id -n
$ sudo usermod -aG docker username
and can restart docker after that:
systemctl restart docker
Upvotes: 5
Reputation: 3132
Starting the Docker daemon
Use following command :
sudo systemctl start docker
or on older distributions, you may need to use:
sudo service docker start
Upvotes: 17
Reputation: 1332
In my particular case the mysql service specified in my docker-compose.yml file had created a volume named mysql_data
in the project root directory. The problem is that this directory, and the contained files had been created with the user 999, and group of docker. So, we have essentially created ourselves a permissions issue which can be mitigated all together by using the techniques discussed in Handling Permissions With Docker Volumes
To remedy the immediate situation, however, you should determine what volume's data is causing the issue. In my particular case it was the mysql_data
volume, so I executed the following, in the project root directory, to change file and directory ownership to that of the currently logged in user:
sudo chown -R ${USER}:${USER} mysql_data
If you are unsure which volume is causing the ownership related issue, to ensure that all of your project's ownership details are the same, you should execute the following in your project root directory:
sudo chown -R ${USER}:${USER} .
Now, if your project is under Git source code control, as a result of executing one of the above commands, you will now have a situation whereby file and directory ownership differs to that of the ownership in git stored objects database. You will most likely encounter errors similar to, "git: Unable to index file", in which case - prior to the further adding and committing of any files to your git project repository, you should ensure that the ownership of the files in the git objects database are an exact mirror of your project's file ownership. You can ensure this by executing the following in the project root:
sudo chown -R ${USER}:${USER} .git/objects
Having now fixed the initial errors you encountered, you can now issue your original docker-compose command, that originally resulted in the "Couldn't Connect to Docker Daemon" error, successfully.
Upvotes: 0
Reputation: 2625
I noticed that I got this error after installing docker-compose. Trying to runsudo docker-compose build
gave me the error --
ERROR: Couldn't connect to Docker daemon. You might need to install Docker
I solved this by installing docker-ce (Ubuntu 16.04 and 18.04). Everything worked as expected thereafter
Upvotes: 0
Reputation: 613
You should add your user in docker group. And then, you can use docker command without 'sudo'.
$ sudo usermod -aG docker ${USER}
$ sudo service docker restart
Next, you have to logout in your OS. Finally, when you login, you can use docker command without 'sudo'.
Upvotes: 12
Reputation: 62559
assuming your environment variables are set using the following shell command :
eval "$(docker-machine env default)"
then you can find the exact error by running the following shell command:
docker-compose --verbose up -d
many times its a proxy issue or if your running it with charles proxy it can block compose from connecting etc. if it is a proxy issue you can add this to your profile:
export no_proxy=192.168.99.100
Upvotes: 39