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?
Disclaimer - did not find an official reasoning for this best practice, but this is what I came up with, hope it makes sense.