build context for docker image very large

0 votes

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?

Aug 1, 2018 in Docker by Hannah
• 16,570 points
4,120 views

1 answer to this question.

0 votes
The Docker client sends the entire "build context" to the 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.
answered Aug 1, 2018 by Kalgi
• 42,430 points

Related Questions In Docker

0 votes
2 answers

How do I force Docker for a clean build of an image ?

You could try this inorder to clean ...READ MORE

answered Aug 6 in Docker by Sirajul
• 38,420 points
1,707 views
0 votes
1 answer

How do I delete the build cache for a docker image?

You could try this inorder to clean ...READ MORE

answered Jul 3 in Docker by Sirajul
• 38,420 points
325 views
+1 vote
1 answer

Build Docker image for PHP Web application - ADD failed

Thank you Sirajul Yes, I have changed it ...READ MORE

answered Jul 15 in Docker by limcw
• 270 points
133 views
0 votes
1 answer

Docker Swarm- Build image only when stack deployed from manager node

Use docker build to build the image. ...READ MORE

answered Aug 24, 2018 in Docker by Nilesh
• 6,880 points
58 views
0 votes
1 answer
0 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 56,940 points
227 views
+1 vote
1 answer

How to push a docker image to a private repository

You need to tag your image correctly ...READ MORE

answered Jul 26, 2018 in Docker by Kalgi
• 42,430 points
105 views
0 votes
1 answer