Build context for docker image very large

842    Asked by Yashraj in Tableau , Asked on Jul 19, 2021

My Dockerfile looks like this:

FROM crystal/centos
MAINTAINER crystal
ADD ./rpms/test.rpm ./rpms/ 
RUN yum -y --nogpgcheck localinstall /rpms/test.rpm

My actual rpm is only 1 GB. But when I try to do sudo docker build -t="crystal/test”., I get sending build context to Docker daemon 3.5 GB. Is there something else that I'm unaware of as you continue to build Docker images? Is my memory accumulating as I build more images in my other directories on my host machine?

Answered by Manish Nagar

The Docker client sends build context to docker daemon. That build context (by default) is the entire directory the Dockerfile is in (so, the entire rpms tree). You can setup a .dockerignore file to get Docker to ignore some files. You might want to experiment with it. Alternatively, you can move your rpms folder one directory level above your Dockerfile, and only symlink test.rpm into the Dockerfile's directory.



Your Answer

Interviews

Parent Categories