I\'m trying to learn about Docker, but I keep getting cryptic (to me) error messages.
Possibly the simplest example of this is trying to print the version of Docker
The underlining problem is simple – lack of permission to /var/run/docker.sock unix domain socket.
From Daemon socket option chapter of Docker Command Line reference for Docker 1.6.0:
By default, a unix domain socket (or IPC socket) is created at
/var/run/docker.sock, requiring either root permission, or docker group membership.
Steps necessary to grant rights to users are nicely described in Docker installation instructions for Fedora:
Granting rights to users to use Docker
The docker command line tool contacts the docker daemon process via a socket file
/var/run/docker.sockowned byroot:root. Though it's recommended to use sudo for docker commands, if users wish to avoid it, an administrator can create a docker group, have it own/var/run/docker.sock, and add users to this group.
$ sudo groupadd docker
$ sudo chown root:docker /var/run/docker.sock
$ sudo usermod -a -G docker $USERNAME
Log out and log back in for above changes to take effect.
Please note that Docker packages of some Linux distributions (Ubuntu) do already place /var/run/docker.sock in the docker group making the first two of above steps unnecessary.
In case of OS X and boot2docker the situation is different; the Docker daemon runs inside a VM so the DOCKER_HOST environment variable must be set to this VM so that the Docker client could find the Docker daemon. This is done by running $(boot2docker shellinit) in the shell.