Tech C**P
15 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
If you are building a docker image using docker build and you want to force building the package use --no-cache:

docker build --no-cache


#docker #build #no_cache #cache #force
In Dockerfile`s some people in the community use `alpine base image in order to reduce docker image size. apk is its package management tool that can be used to install OS packages. So for example if
you want to install network tools (like ping) you need to install netcat-openbsd:

apk add netcat-openbsd


You can squash your image size even further by some tips. When you install a package, linux distros first download the package and put it in a cache folder. In Alpine it is located in /var/cache/apk.
To tell the OS to delete the cache after installation you can provide --no-cache option to it:

apk add --no-cache netcat-openbsd


There are some package like g++ or git that is needed on installation of some other packages. After installation those packages is useless and just increase image size. You can remove those packages b
y using --virtual command:

apk add --no-cache --virtual .build-deps g++ \
&& # do you stuff here \
&& apk del .build-deps


Great job guys! You have reduced your alpine docker images so much :)

#docker #linux #alpine #apk #virtual #no_cache #apk_del #apk_add