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
• 18,520 points
14,654 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
• 52,350 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, 2019 in Docker by Sirajul
• 59,230 points
10,693 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, 2019 in Docker by Sirajul
• 59,230 points
12,630 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, 2019 in Docker by limcw
• 270 points
2,630 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
• 7,060 points
1,287 views
+2 votes
1 answer
+2 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
• 58,020 points
2,714 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
• 52,350 points
2,252 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP