Reduce Docker image size can help your to portable your contain across network, save bandwidth and storage, faster to scale.
It is minimal Docker image based on Alpine Linux that only 5 MB.
You can install packages with
apk add --update <pakckages> and
you can check packages that avaible on alpine packages.
You can see how small alpine based image are. However alpine based is new born linux that not contain much packages as older linux like debian/ubuntu. There are some compiled packages and some that your have to compile with your own.
--no-install-recommendsoption on Debian/Ubuntu Image
with this option, Marc Campbell can drop ~120MB for
and I can save ~700MB by using this technique and combine commands on
that based on sphereio/docker-predictionio.
RUN apt-get install -y --no-install-recommends <packages>
Dockfile look like
RUN apt-get update RUN apt-get install -y python-pip RUN pip install predictionio
should combile commands like this
RUN apt-get update \ && apt-get install -y python-pip \ && pip install predictionio
that reduce image layer and image size.
However your should do this when your sure with
docker build will cache a huge layer, you need to rebuild all
commands if your edit any single one.
Remove some no longer need packages ex.
curl Any SDK
and compressed file that your extracted when you finish your
Must remove in same layer, remove in another layer not help to reduce image size.
RUN apt-get install -y python-pip pyhton-dev \ && pip install predictionio \ && apt-get remove -y python-pip \ && ap-get clean \ && rm -rf /var/lib/apt/lists/*
I not sure about this solution that I can’t complie it on OSX. You can read more about