Use a ‘slim’ runtime picture
For a lot of functions written in languages that require a runtime, you should use a “slim” runtime picture for the language. These are prebuilt photographs that comprise the naked minimal of what’s wanted to launch and run an utility written within the given language.
It’s value saying once more that slim photographs solely provide you with what’s wanted to assist the runtime itself, not your specific utility. As an illustration, if in case you have a Python utility that wants third-party packages from PyPI, you need to add these as a part of the picture construct course of (RUN pip set up, and so on.).
One other good supply for slender base photographs, constructed for particular use instances, is the Google Distroless Picture assortment. They’re constructed on prime of stripped-down cases of Debian Linux, run on a number of architectures, and supply included runtimes for Python 3, C-compiled packages, Java (together with variations 17 and 21), and Node.js (variations 18, 20, and 22). They don’t comprise shells or package deal managers, so you need to configure your Dockerfile’s ENTRYPOINT so it received’t try to make use of a shell (e.g., ENTRYPOINT ["start"] as an alternative of ENTRYPOINT "begin") or provide arguments to the language runtime configured because the default.
