Alex
Alex

Reputation: 44395

Cannot run docker 'hello world' example

I just installed docker on a Mac (docker toolbox from here; at least I hope to have it installed correctly), but when following the tutorial and type the following command

docker run hello-world

I get the following error:

docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.

Did I do something wrong? Do I miss some installation steps? Do I miss something that is 'obvious' to the experts, but not to docker beginners like me?

I don't see anything in the instructions that says anything about a 'docker daemon'...

On the shell it says:

docker is configured to use the default machine with IP aa.bb.cc.d

The version command seems to work:

Docker version 17.07.0-ce, build 8784753

Update:

I tried to start the daemon by using the command

sudo dockerd

but all I got was

sudo: dockerd: command not found

Correction: The command works, but only in the sell that opened magically during the installation. The command does not work in any other shell. But when I have to close the shell/restart the computer - what to do then? How to 'start docker???

Maybe there is a tutorial that is complete and working and explains why I need a docker-deacon, how to start it, how to start a docker image or whatever, including the complete terminology for beginners?

Upvotes: 2

Views: 2758

Answers (3)

BMitch
BMitch

Reputation: 264831

With docker toolbox, if you don't launch your terminal from the docker menu, you'll need to configure your environment separately:

eval "$(docker-machine env default)"

Upvotes: 1

tkausl
tkausl

Reputation: 14279

Docker Toolbox runs a virtual linux machine on which the docker-daemon runs. To control the virtual machine, you use the docker-machine command. For example docker-machine start to start the machine after you reboot your computer, or docker-machine stop to shut it down.

There is also the docker-machine env command which will set the environment variables needed for docker to work. Check the bottom line of it's output, it shows you how to run the command correctly to set the environment variables. Should be exec $(docker-machine env) on Mac if I'm correct. You need to set the environment variables in each shell in which you want to use docker commands.

Upvotes: 3

yamenk
yamenk

Reputation: 51876

Docker for mac starts a linux virtual machine in the background which contains the actual docker stuff. When you start a normal terminal, the terminal is not connected to the vm to execute the docker commands.

The docker quick start terminal is the one that you need to use. This terminal will execute the commands on the VM that is running in the background.

Upvotes: 0

Related Questions