-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Reduce docker image size #1308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce docker image size #1308
Conversation
The final docker image size is reduced about 2GB by cleaning up the apt files and removing unneeded compressed files.
|
||
# build dependencies | ||
# https://buildozer.readthedocs.io/en/latest/installation.html#android-on-ubuntu-16-04-64bit | ||
RUN dpkg --add-architecture i386 && apt update -qq && apt install -qq --yes --no-install-recommends \ | ||
build-essential ccache git libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 \ | ||
libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev \ | ||
openjdk-8-jdk unzip zlib1g-dev zlib1g:i386 | ||
openjdk-8-jdk unzip zlib1g-dev zlib1g:i386 && \ | ||
rm -rf /var/lib/apt/lists/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why running it twice rather than once at the end?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because, as far as i know, and I'm pretty new on docker, each run command creates a layer (a kind of diff that depends on other layers) so...to prevent inherited layers to have the files that we don't need, we must remove them before the next run command.
Refs:
https://hackernoon.com/tips-to-reduce-docker-image-sizes-876095da3b34
https://www.ianlewis.org/en/creating-smaller-docker-images
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I was suspecting that, wanted to make sure. Thanks!
Thank you very much for taking a look at this. In fact I didn't remove these files on purpose for 2 reasons:
So I didn't see the point reducing the size. But I'm open to discussions regarding it. Just that often when I clean my Docker image, I end up being annoyed when I want to verify/update/debug things from the interactive shell. |
I think that once we unzip/untar/install all the ndk/sdk/apt files there is no need to have those in our system...I think that are useless for debugging purposes...unless we could reuse it when we do another image....but i don't thing that docker use that (unless we create another image based on that image...but if we do that we already have again the uncompressed files...again useless). I found an answer in stackoverflow that talks about the docker caching system that could clarify a little how the caching system of docker works: https://stackoverflow.com/questions/25102272/why-doesnt-docker-hub-cache-automated-build-repositories-as-the-images-are-bein The point of reducing docker image size will benefit all of those who work with ssd disks, who have limited disk space. Saying all that, maybe i miss some point about interactive shell debugging and the use of those compressed files...I don't see why we should keep them...Maybe I miss something? |
An example where I had to use the archive was to play with the |
The final docker image size is reduced about 2GB by cleaning up the apt files and removing unneeded compressed files.