I installed docker-machine 0.1.0 and docker-compose 1.1.0 on Mac OS 10.8.5.
Docker-machine is running normally and able to connect by docker-machine ssh.
Anyone checked log ?
In my case error message in /var/log/upstart/docker.log
was:
Listening for HTTP on unix (/var/run/docker.sock)
[graphdriver] using prior storage driver "aufs"
Running modprobe bridge nf_nat failed with message: , error: exit status 1
Error starting daemon: Error initializing network controller: Error creating default "bridge" network: can't find an address range for interface "docker0"
Worth to mentioned I had vpn turned on, so:
$ sudo service openvpn stop
$ sudo service docker restart
$ docker-compose up|start
$ sudo service openvpn start
was the solution.
Answer from @srfrnk works for me.
In my situation, I had the next docker-compose.yml file:
nginx:
build:
context: ./
dockerfile: "./docker/nginx.staging/Dockerfile"
depends_on:
- scripts
environment:
NGINX_SERVER_NAME: "some.host"
NGINX_STATIC_CONTENT_OPEN_FILE_CACHE: "off"
NGINX_ERROR_LOG_LEVEL: debug
NGINX_BACKEND_HOST: scripts
NGINX_SERVER_ROOT: /var/www/html
volumes:
- ./docker-runtime/drupal/files:/var/www/html/sites/default/files:rw
ports:
- 80:80
./docker-runtime
owner and group - is root
when the other files owner - my user.
When I tried to build nginx
Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?
I added ./docker-runtime
to .dockerignore
and it is solved my problem.
I've had the same symptoms.
Only diff that it happened only during docker-compose build
docker ps
worked.
Happened with version 2.x
as well as 3.x
.
Restarted docker
service, then the machine...
Even re-installed docker
+ docker-compose
.
Tried everything but nothing helped.
Finally I tried building the Dockerfile "manually" by using docker build
.
Apparently I had a permission issue on a file/folder inside the Docker
context. It was trying to read the context when starting the build and failed with a proper error message.
However this error message did not propagate to docker-compose
which only shows Couldn't connect to Docker daemon at http+unix://var/run/docker.sock - is it running?
Having found that the solution was simply adding the file/folder to the .dockerignore
file since it wasn't needed for the build. Another solution might have been to chown
or chmod
it.
Anyway maybe this could help someone coming across the same issue that really has nothing to do with docker
and the misleading error message being displayed.
The Docker machine is running. But you need to export some environment to connect to the Docker machine. By default, the docker
CLI client is trying to communicate to the daemon using http+unix://var/run/docker.sock
(as shown in the error message).
Export the correct environment variables using eval $(docker-machine env dev)
and then try again. You can also just run docker-machine env dev
to see the environment variables it will export. Notice that one of them is DOCKER_HOST
, just as the error message suggests you may need to set.
Simple solution for me: sudo docker-compose up
UPDATE 2016-3-14: At some point in the docker install process (or docker-compose ?) there is a suggestion and example to add your username to the "docker" group. This allows you to avoid needing "sudo" before all docker commands, like so:
~ > docker run -it ubuntu /bin/bash
root@665d1ea76b8d:/# date
Mon Mar 14 23:43:36 UTC 2016
root@665d1ea76b8d:/# exit
exit
~ >
Look carefully at the output of the install commands (both docker & the 2nd install for docker-compose) and you'll find the necessary step. It is also documented here: https://subosito.com/posts/docker-tips/
Sudo? No!
Tired of typing sudo docker everytime you issue a command? Yeah, there is a way for dealing with that. Although naturally docker is require a root user, we can give a root-equivalent group for docker operations.
You can create a group called docker, then add desired user to that group. After restarting docker service, the user will no need to type sudo each time do docker operations. How it looks like on a shell commands? as a root, here you go:
> sudo groupadd docker
> sudo gpasswd -a username docker
> sudo service docker restart
Done!
This section contains optional procedures for configuring Linux hosts to work better with Docker.
Manage Docker as a non-root user
The docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root and other users can only access it using sudo. The docker daemon always runs as the root user.
If you don’t want to use sudo when you use the docker command, create a Unix group called docker and add users to it. When the docker daemon starts, it makes the ownership of the Unix socket read/writable by the docker group.
To create the docker group and add your user:
# 1. Create the docker group.
$ sudo groupadd docker
# 2. Add your user to the docker group.
$ sudo usermod -aG docker $USER
# 3. Log out and log back in so that your group membership is re-evaluated.
# 4. Verify that you can run docker commands without sudo.
$ docker run hello-world
This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.
while running docker-compose pull
- i was getting below error
ERROR: Couldn't connect to Docker daemon at http+docker://localhost
is it running?
solution -
sudo service docker start
issue resolved