1

MacOS Sierra 10.12.2

Docker 1.12.5

New to Docker, this error appears every time I try to build a Docker file:

$ sudo docker build -t tutorial .
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

I followed the instructions from this SO post but the the problem wasn't solved: Docker can't connect to docker daemon

Docker version:

$ docker --version
Docker version 1.12.5, build ...

The directory:

$ ls
Dockerfile  README.md   apache      supervisord

Start virtual machine for Docker:

$ docker-machine start
Starting "default"...
Machine "default" is already running.
...
$ docker-machine env
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.00.00:2576" #edit
export DOCKER_CERT_PATH="/Users/myUser/.docker/machine/machines/default"
export DOCKER_MACHINE_NAME="default"
# Run this command to configure your shell: 
# eval $(docker-machine env)
...
$ eval "$(docker-machine env default)"

Run it again:

$ sudo docker build -t tutorial .
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

SOLVED: does works without sudo:

$ docker build -t tutorial .

Community
  • 1
  • 1
XY6
  • 3,082
  • 4
  • 21
  • 26

1 Answers1

1

Try run this command docker build -t tutorial . without sudo or run eval "$(docker-machine env default)" with sudo

mmp4k
  • 46
  • 2
  • 1
    @user1644677 - `eval "$(docker-machine env default)"` creates some variables in your terminal session, but when you are using sudo you are login as another user (`root`), so, you haven't access to that docker variables. – mmp4k Mar 03 '17 at 20:38