Search code examples
scaladockersbtsbt-native-packager

How to set base image for DockerPlugin of sbt native packager?


I want to dockerify a scala application.

I use the sbt-native-packager, and when building the image locally via

sbt docker:publishLocal

I was surprised to realize that it would use:

openjdk:latest

as its base image.

I like to point my docker image against certain version, and I know that my application currently require Java 8 and will crash on Java 9; and the latest tag might point to a new major version in the future.

I am a bit confused on how the Docker plugin works through sbt-native-packager. Why is it using openjdk:latest as its base? How can I set it to something different, e.g.: openjdk/8-jdk?


Solution

  • You can set the baseImage and its tag in your build.sbt through:

    dockerBaseImage := "openjdk:8-jdk"
    

    You can read about this in the docker documentation of the sbt native packager.