我想在docker图像中添加sbt。我基于Dockerfile图像创建了一个centos:centos8:

FROM centos:centos8
ENV SCALA_VERSION 2.13.1
ENV SBT_VERSION 0.13.18

RUN  yum install -y epel-release
RUN  yum update -y && yum install -y wget

RUN wget -O /usr/local/bin/sbt-launch.jar http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/$SBT_VERSION/sbt-launch.jar

WORKDIR /root
EXPOSE 8080

RUN sbt compile
CMD sbt run

而且我还需要在此处安装sbt,但是运行此脚本时出现错误:
Step 10/11 : RUN sbt compile
 ---> Running in 0aadcd774ba0
/bin/sh: sbt: command not found

我不明白为什么找不到sbt。这是实现我所需要的一种好方法还是我应该尝试其他方法?但是我需要用centos
编辑:

最终,它会在以下答案的帮助下起作用。工作脚本如下所示:
FROM centos:centos8
ENV SBT_VERSION 0.13.17

RUN yum install -y java-11-openjdk && \
    yum install -y epel-release && \
    yum update -y && yum install -y wget && \
    wget http://dl.bintray.com/sbt/rpm/sbt-$SBT_VERSION.rpm && \
    yum install -y sbt-$SBT_VERSION.rpm

WORKDIR /root
EXPOSE 8080

RUN sbt compile
CMD sbt run

最佳答案

您需要在sbt中安装Dockerfile。这是一个例子:

FROM centos:centos8
ENV SCALA_VERSION 2.13.1
ENV SBT_VERSION 0.13.17

RUN yum install -y epel-release
RUN yum update -y && yum install -y wget

# INSTALL JAVA
RUN yum install -y java-11-openjdk

# INSTALL SBT
RUN wget http://dl.bintray.com/sbt/rpm/sbt-${SBT_VERSION}.rpm
RUN yum install -y sbt-${SBT_VERSION}.rpm

RUN wget -O /usr/local/bin/sbt-launch.jar http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/$SBT_VERSION/sbt-launch.jar

WORKDIR /root
EXPOSE 8080

RUN sbt compile
CMD sbt run


注意:我没有在env变量(0.13.18)中看到您使用的版本,因此将其更改为0.13.17。

关于docker - Docker,sbt-无法使用centos docker镜像安装sbt,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59992384/

10-16 04:03