在Docker映像中安装sdkman

时间:2018-12-06 17:13:37

标签: docker ubuntu sdk docker-compose

在ubantu映像中安装sdkman时出错。

FROM ubuntu:16.04
RUN apt-get update
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
RUN apt-get -qq -y install curl
RUN curl -s https://get.sdkman.io | bash
RUN chmod a+x "$HOME/.sdkman/bin/sdkman-init.sh"
RUN source "$HOME/.sdkman/bin/sdkman-init.sh"

3 个答案:

答案 0 :(得分:1)

从ubuntu:16.04 运行apt更新 运行apt-get -qq -y install \     卷曲     解压     压缩 运行rm / bin / sh && ln -s / bin / bash / bin / sh 运行apt-get -qq -y install curl 运行curl -s https://get.sdkman.io |重击 运行chmod a + x“ $ HOME / .sdkman / bin / sdkman-init.sh”

运行源“ $ HOME / .sdkman / bin / sdkman-init.sh”

答案 1 :(得分:0)

安装unzipzip,这意味着进行更改

RUN apt-get -qq -y install curl

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

或更佳

RUN apt-get -qq -y install \
    curl \
    unzip \
    zip

当您尝试构建Dockerfile时,您将获得

    .....

    Step 5/6 : RUN curl -s https://get.sdkman.io | bash
    ---> Running in 1ce678a59561

    --- SDKMAN LOGO ---

    Now attempting installation...

    Looking for a previous installation of SDKMAN...
    Looking for unzip...
    Not found.
    ======================================================================================================
    Please install unzip on your system using your favourite package manager.

    Restart after installing unzip.
    ======================================================================================================

    Removing intermediate container 1ce678a59561
    ---> 22211eafd50c
    Step 6/6 : RUN source "$HOME/.sdkman/bin/sdkman-init.sh"
    ---> Running in 1c5cb7d79ef0
    /bin/sh: /root/.sdkman/bin/sdkman-init.sh: No such file or directory
    The command '/bin/sh -c source "$HOME/.sdkman/bin/sdkman-init.sh"' returned a non-zero code: 1

您需要做的就是在那里写的。

    ======================================================================================================
    Please install unzip on your system using your favourite package manager.

    Restart after installing unzip.
    ======================================================================================================

在安装解压缩文件时,您会看到与zip相同的错误,安装后一切正常。

因此,请阅读日志/命令输出。特别是在这里,它真的很明显:-)

P.S。如果curl -s https://get.sdkman.io | bash用非零代码退出会更好,在构建失败的地方更好地看到它。这样,它在下一个命令上将失败。但这不是您可以解决的。

答案 2 :(得分:0)

看来sdkman安装失败。 当我在上面运行您的代码时,它抱怨缺少unzipzip软件包。

满足依赖性后,还需要使用以下命令将初始化脚本标记为可执行文件:

chmod a+x "$HOME/.sdkman/bin/sdkman-init.sh"

因此您的Dockerfile应该类似于:

FROM ubuntu:16.04
RUN apt-get update
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
RUN apt-get -q -y install curl zip unzip
RUN curl -s https://get.sdkman.io | bash
RUN chmod a+x "$HOME/.sdkman/bin/sdkman-init.sh"
RUN source "$HOME/.sdkman/bin/sdkman-init.sh"

P.S:受到打击!