Reputation: 2179
I have a somewhat peculiar scenario. I tend to execute command docker-compose -f dev.yml up --build
to get the containers up and work. Here, dev.yml
is development version of docker-compose.yml
. Till this very morning every thing was working fine, and all of the sudden, I started getting error regarding failure to connect to docker-daemon.
Now, this problem only occurs when I have --build
included in the command. If I only execute docker-compose -f dev.yml up
it works fine. If I include --build
into the command and execute it using sudo
it works fine again.
Things verified:
/var/run/docker.sock
Details of dev.yml
version: '2'
volumes:
postgres_data_dev: {}
postgres_backup_dev: {}
services:
postgres:
build: ./compose/postgres
volumes:
- postgres_data_dev:/var/lib/postgresql/data
- postgres_backup_dev:/backups
environment:
- POSTGRES_USER=rocky
django:
build:
context: .
dockerfile: ./compose/django/development/Dockerfile
depends_on:
- postgres
environment:
- POSTGRES_USER=rocky
- USE_DOCKER=yes
volumes:
- .:/app
- /tmp/
links:
- postgres
- redis
expose:
- "8000"
env_file:
- ./dev.env
nginx:
build:
context: .
dockerfile: ./compose/nginx/development/Dockerfile
depends_on:
- django
ports:
- "0.0.0.0:80:80"
links:
- django
volumes_from:
- django
redis:
image: redis:latest
hostname: redis
celeryworker:
build:
context: .
dockerfile: ./compose/django/development/Dockerfile
env_file: ./dev.env
depends_on:
- django
- redis
- postgres
volumes_from:
- django
command: celery -A rocky.taskapp worker -l INFO
restart: on-failure
celerybeat:
build:
context: .
dockerfile: ./compose/django/development/Dockerfile
env_file: ./dev.env
depends_on:
- django
- redis
- postgres
- celeryworker
volumes_from:
- django
command: celery -A rocky.taskapp beat -l INFO
Update: My colleague got stuck with same issue. I have my doubts on config for celerybeat, celeryworker. Can anyone please verify? Thanks.
Upvotes: 20
Views: 13678
Reputation: 309
Use $ sudo service docker start
or $ sudo systemctl start docker
to start the docker daemon back again if it was stopped somehow.
Also you may have to add your user to the docker group, eg. using sudo usermod -aG docker $(whoami)
. This requires opening a new shell to take effect!
Upvotes: 4
Reputation: 11
Its dumb, but in my case, in docker-compose.yml I kept uppercase name for image and was getting that error. I checked my docker logs and finally fixed that name to lowercase.
Upvotes: 1
Reputation: 20756
So maybe running with sudo
can fix your problem but you should ensure that your user can access to Docker engine with the current privileges without sudo. Solution is so simple.
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker
Upvotes: 1
Reputation: 13680
Restarting docker service fixed the problem for me.
$ systemctl restart docker.service
Upvotes: 0
Reputation: 22196
I ran into this issue after a fresh install of docker
and docker-compose
on Ubuntu, trying to run docker-compose up
. I managed to solve it as described here by adding my user to the docker
group:
sudo usermod -aG docker ${USER}
and logging out and back in.
You may be able to avoid having to log out and back in as described here by running
su - $USER
Upvotes: 13
Reputation: 2179
For me the following command worked,
sudo chown $USER:$USER -R .
Check this conversation I had on github, Issue
Upvotes: 18
Reputation: 8497
This is most like a permissions issue and docker-compose is giving entirely the wrong error.
Try building the images by hand with docker
instead of docker-compose
, e.g.
docker build -f=./compose/django/development/Dockerfile .
and likely you will see what the real issue is.
Upvotes: 4