Search code examples
dockeralpine-linuxsdkman

Install Sdkman in an Alpine based Docker Image


I need to install Sdkman in an Alpine based docker image, but there is a problem that default shell is not Bash. Then command:

source "$HOME/.sdkman/bin/sdkman-init.sh"

ends with failure:

/bin/sh: /root/.sdkman/bin/sdkman-init.sh: line 40: SDKMAN_PLATFORM+=64: not found 

Solution

  • You'll need to split the install of SDKMAN and running the init script into two RUN blocks e.g.

    RUN apk add bash curl git zip && \
      curl -s "https://get.sdkman.io" | bash
    RUN bash -c "source $HOME/.sdkman/bin/sdkman-init.sh && sdk version"
    

    Source: https://e.printstacktrace.blog/using-sdkman-as-a-docker-image-for-jenkins-pipeline-a-step-by-step-guide/