klogg icon indicating copy to clipboard operation
klogg copied to clipboard

Optimize Dockerfiles for all Docker images

Open PeterDaveHello opened this issue 2 years ago • 1 comments

This commit optimizes the Dockerfiles for both Oracle and Ubuntu Docker images to enhance efficiency, reduce image size, and ensure adherence to best practices.

  1. Consolidate RUN commands: This reduces Docker image layers and allows effective cleanup within the same layer.

  2. Standardize on apt-get over apt: apt is designed for interactive use, while apt-get provides a stable CLI interface for scripting. This change ensures script stability and consistency in Dockerfiles.

  3. Adjust package installation: Use --no-install-recommends with apt-get install to avoid unnecessary packages and explicitly install ca-certificates in Ubuntu Docker images for wget to function correctly with HTTPS.

  4. Remove temporary installation files: Further reduces Docker image size by cleaning up unused files post-installation.

These changes overall streamline the Dockerfiles, leading to more efficient and smaller Docker images.

Here's the result of the optimization, which is significant:

REPOSITORY             TAG        IMAGE ID       CREATED        SIZE
ubuntu22.04            after      ba8a163bd647   1 hours ago    1.22GB
ubuntu22.04            before     444d0d9ade14   1 hours ago    1.51GB
ubuntu20.04            after      9cfbaf385492   1 hours ago    1.15GB
ubuntu20.04            before     1f77992b16dc   1 hours ago    1.89GB
ubuntu18.04_qt5.15     after      6a3c4b985091   1 hours ago    1.13GB
ubuntu18.04_qt5.15     before     904e72f3c332   1 hours ago    1.24GB
ubuntu18.04            after      f2be07fdd124   1 hours ago    953MB
ubuntu18.04            before     72288345a99f   1 hours ago    1.17GB
oracle8                after      91fa597e5366   1 hours ago    1.1GB
oracle8                before     e4cb6d5953d2   1 hours ago    1.63GB
oracle7                after      4b03e24f6a86   1 hours ago    913MB
oracle7                before     cf32ac6dfd47   1 hours ago    1.91GB

PeterDaveHello avatar Oct 02 '23 17:10 PeterDaveHello

@variar the improvement result is huge, you may want to take a look ;)

PeterDaveHello avatar Oct 14 '23 16:10 PeterDaveHello