Unable to install sdkman in Ubuntu Docker


I am trying to install sdkman in docker, I am following their official instructions, but it's failing at the following last step

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

Following is my Dockerfile content

FROM ubuntu:18.04

RUN apt-get update
RUN apt-get -qq -y install curl wget unzip zip

RUN curl -s "https://get.sdkman.io" | bash
RUN source "$HOME/.sdkman/bin/sdkman-init.sh"

Following is the full output of the step

Step 5/5 : RUN source "$HOME/.sdkman/bin/sdkman-init.sh"
 ---> Running in 739a02da681f
/bin/sh: 1: source: not found
The command '/bin/sh -c source "$HOME/.sdkman/bin/sdkman-init.sh"' returned a non-zero code: 127

1 Answer

5 years ago by

Error is because of missing Bashism, Add the following to your Dockerfile that should fix the problem

RUN rm /bin/sh && ln -s /bin/bash /bin/sh

with that, your Dockerfile should look like following

FROM ubuntu:18.04

RUN apt-get update
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
RUN apt-get -qq -y install curl wget unzip zip

RUN curl -s "https://get.sdkman.io" | bash
RUN source "$HOME/.sdkman/bin/sdkman-init.sh"
5 years ago by Karthik Divi