Cannot connect to the Docker daemon when running with sudo

The following command exports a few environment variables that the subsequent docker commands use:

eval "$(docker-machine env default)"

However, if you launch docker with sudo, the exported environment variables are not accessible by the docker executable. You could potentially get it to work by passing -E flag to sudo, e.g.:

sudo -E docker pull fluxcapacitor/pipeline

But much easier option is to use docker without root like:

docker pull fluxcapacitor/pipeline

You have to set environment variables with:

eval "$(docker-machine env default)"

More about it here.

Tags:

Docker

Macos