Ubuntu 16.04 - > ERROR: Couldn't connect to Docker daemon - you might need to run `docker-machine start default`

天大地大妈咪最大 提交于 2020-01-01 01:47:09

问题


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 ?


回答1:


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



回答2:


If you installed Docker as a snap package try this:

sudo snap start docker



回答3:


Starting the Docker daemon

Use following command :

sudo systemctl start docker  

or on older distributions, you may need to use:

sudo service docker start



回答4:


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'.




回答5:


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




回答6:


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.




回答7:


We need to restart the docker

$ sudo service docker restart

click here




回答8:


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



回答9:


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} .



回答10:


My issue was that I was missing $ sign in front of variable in the image name

image: imagename:{TAG:-develop-latest}



回答11:


Try running with root: sudo docker-compose build



来源:https://stackoverflow.com/questions/40159225/ubuntu-16-04-error-couldnt-connect-to-docker-daemon-you-might-need-to-ru

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!