How to Fix ERROR Couldn’t connect to Docker daemon at http+docker://localunixsocket

Ubuntu16.04 executes docker in the directory where the docker-compose. Yml file is located after installing docker:

jing@ubuntu:/tmp/docker$ docker-compose up -d

Error:

ERROR: Couldn’t connect to Docker Daemon at HTTP + Docker :// localunixSock-is it running?
If it’s at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

Online all kinds of way seven eight bad solution, really ridicule.
What is correct is to add the current user to the Docker group

jing@ubuntu:/tmp/docker$ sudo gpasswd -a ${USER} docker

Then exit the current user and switch to, say, root and then switch to Jing again. Then execute Docker-Compose up-D and it will be ok.

jing@ubuntu:/tmp/docker$ sudo su
root@ubuntu:/tmp/docker$ su jing
jing@ubuntu:/tmp/docker$ docker-compose up -d

Read More: