Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker: Couldn't connect to docker daemon at http+docker://localunixsocket -is it running?

Tags:

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:

  • User executing the command is added to docker group which has permissions for /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.

like image 254
Rajesh Yogeshwar Avatar asked Jun 28 '17 10:06

Rajesh Yogeshwar


1 Answers

For me the following command worked,

sudo chown $USER:$USER -R .

Check this conversation I had on github, Issue

like image 76
Rajesh Yogeshwar Avatar answered Oct 30 '22 18:10

Rajesh Yogeshwar