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:

[email protected]:/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

[email protected]:/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.

[email protected]:/tmp/docker$ sudo su
[email protected]:/tmp/docker$ su jing
[email protected]:/tmp/docker$ docker-compose up -d

Read More: