I am getting error on ubuntu 16.04
\"ERROR: Couldn\'t connect to Docker daemon - you might need to run
docker- machine start default
. \"
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.