How does the official openjdk image differ from ubuntu + openjdk?

Viewed 138

This is a recommendation from Docker official best practices

Start with an appropriate base image. For instance, if you need a JDK, consider basing your image on the official openjdk image, rather than starting with a generic ubuntu image and installing openjdk as part of the Dockerfile.

But I do not follow how the official openjdk image would be different from ubuntu + openjdk ? Is it because the official openjdk image uses a lighter linux distribution than ubuntu?

1 Answers
  1. Adding layers, software, configs etc in your Dockerfile is potentially error prone. Adding a single package might not seem much but as soon as complexity is growing, OS tweaks applied etc, it comes in handy to have this done for you by a vendor/community in the base image.
  2. Sharing as many layers as possible between containers improves resource efficiency. Image layers which are same between containers can be reused. So, if there's many application instances running on a host, it can have a real impact if they all use a shared openjdk base image with few additional layers, or just a shared ubuntu image with openjdk installed via Dockerfile (which might differ in versions, configurations, ...)

Disclaimer - did not find an official reasoning for this best practice, but this is what I came up with, hope it makes sense.

Related