How to build docker image inside docker container?

30 views Asked by At

I am not sure I am doing it correct or not but I am trying to build a docker image inside docker container.

I think this can be achieve by using Docker-in-Docker but whenever I am trying to do that I am getting a following error while building an image:

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Here is my Dockerfile

# FROM alpinelinux/docker-cli
FROM docker:latest

RUN apk update
RUN apk upgrade

RUN apk add git

ENV REPOSITORY_URL=https://github.com/shahinadev/create-react-app.git
ENV PROJECT_NAME=create-react-app

RUN git clone ${REPOSITORY_URL} ${PROJECT_NAME}

WORKDIR ${PROJECT_NAME}

COPY Dockerfile Dockerfile

RUN docker build -t ${PROJECT_NAME} .

Actual Result: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Expected Result: Image should build so that I can push it to the remote container registry

0

There are 0 answers