Grzegorz Piwowarek
Grzegorz Piwowarek

Reputation: 13803

Freeing unnecessary Docker image's space

I have a maven project that I am building and running inside Docker container. My maven build needs to have an access to my project's GIT repository for some commit info extraction so I need to temporarily include my repository inside an image.

The problem is that my repository weights more than 600MB and it makes my image unnecessarily huge. I cannot add my repo to an image, perform some action and then remove it later. Well, I can. But it will not save any space due to nature of Docker images. Any ideas on how to deal with this?

Upvotes: 1

Views: 55

Answers (2)

Grzegorz Piwowarek
Grzegorz Piwowarek

Reputation: 13803

Circling back to this one a few years later and now the above problem is solved by multi-stage builds.

Upvotes: 0

VonC
VonC

Reputation: 1325337

You could consider accessing the git repo through a host volume mounted in your docker container.

Or you could consider cloning only the part of the git repo you need (just one branch, only a few commits as a shallow clone). That would minimize the size of the git repo in the image.

Upvotes: 2

Related Questions