“No dockerHost given, no DOCKER_HOST environment variable” error in Ubuntu

I was struggling against an issue of:

No <dockerHost> given, no DOCKER_HOST environment variable, no read/writable '/var/run/docker.sock' or '//./pipe/docker_engine' and no external provider like Docker machine configured

while trying to deploy a project to docker using docker-maven-plugin.

Need to say that I’ve installed and created a docker-machine and then exported all related env‘s to the Ubuntu environment variables. Then I tried to execute the following maven goals using maven from Intellij IDEA:

mvn clean install -pdocker

In my case the solution was hided behind permissions. Just open the terminal in the project folder (where your pom.xml file is) and execute the same command prefixed with sudo:

sudo mvn clean install -pdocker

Seems that docker-maven-plugin had not enough permissions to use docker commands.