I use SdkMan! as is shown here: Install sdkman in docker image . Sdkman! will install any version of Maven I have ever needed, along with a specific version of Java that may not be the version of java that comes with your OS used in the Docker image.