0
votes

I'm getting this error on alpine base docker container: "Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?" when I running the following command: docker images I'm using the following docker-compose:

services:
  alpine:
    build:
      context: ./
      dockerfile: Dockerfile
#      command: -H unix:///var/run/docker.sock
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

and this is my dockerFile:

FROM yossigilad/alpine8:v1 AS prepare
#FROM openjdk:8-jdk-alpine AS prepare
RUN mkdir -p /app/source
#copying all project files to docker
COPY  . /app/source
WORKDIR /app/source
RUN docker images

when I running the container with this command its ok docker run -ti -v /var/run/docker.sock:/var/run/docker.sock DOCKER_ID

What I'm missing?

1
Why are you running docker images inside a build ? What are you trying to achieve ? The volumes are mounted for the container launched after the build from the resulting image, not during the build. So you won't see any docker service running unless you launch one yourself directly in the layer your are currently building. But I don't really get where this is going.Zeitounator
This usually happens whenever you didn't stop dockerAshok
The docker images command is just for checking, I need to run gradle build that also creating a docker image and run component testsYossi Gilad

1 Answers

0
votes

Try the below steps which worked for me

  1. service docker stop
  2. cd /var/run/docker/libcontainerd
  3. rm -rf containerd/*
  4. rm -f docker-containerd.pid
  5. service docker start
  6. docker run