Docker Community Forums

Share and learn in the Docker community.

Can not reduce size of the docker image after deleting the build tools from child image that were installed in base image


(Shubham9792) #1


I am using docker-alpine 3.3 as the base image and building another image from it. Following is the dockerfile for this

FROM xxx/alpine3.3:latest
RUN apk update
RUN apk add --update bash
RUN apk add --update nodejs
RUN apk add --update curl
RUN npm install -g gulp-cli
RUN apk add --update python

RUN apk add --update make
RUN apk add --update g++

Then this created docker images is used as the base image for another docker file where I do npm install and then remove the build tools like python, make and g++ after npm install. Following is the docker file
FROM dockerbase:latest
COPY common /opt/project1324/common
RUN /usr/bin/npm install
RUN apk del python
RUN apk del make
RUN apk del g++

But the size of the docker image has no difference for the cases when I delete those packages and do not delete those packages. Infact, the size is a little bit more when I delete those packages.

Is there a way to delete those build tools from all the layers of docker image so that the size of the docker image decreases.

How can I remove these build tools?