Docker,sbt-无法使用centos Docker映像安装sbt

Docker,sbt-无法使用centos Docker映像安装sbt,docker,centos,sbt,dockerfile,Docker,Centos,Sbt,Dockerfile,我希望在我的docker图像中有sbt。我根据centos:centos8image: 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://rep

我希望在我的
docker
图像中有sbt。我根据
centos:centos8
image:

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

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

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。

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

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。我遇到了一个问题,bintray.com随机返回403。我想这可能是某种交通节流阀。在本地添加了rpm文件

COPY sbt-0.13.18.rpm /
RUN yum install -y sbt-0.13.18.rpm

我遇到了bintray.com随机返回403的问题。我想这可能是某种交通节流阀。在本地添加了rpm文件

COPY sbt-0.13.18.rpm /
RUN yum install -y sbt-0.13.18.rpm

我认为Dockerfile中的任何内容都不会在系统路径中创建名为
sbt
的可执行文件。仅仅下载一个jar文件并不能做到这一点。我认为Dockerfile中的任何内容都不会在系统路径中创建名为
sbt
的可执行文件。仅仅下载一个jar文件是不行的。它对你有用吗?我得到了
命令'/bin/sh-c yum install sbt-${sbt_VERSION}.rpm'返回了一个非零代码:1
忘记了
-y
。我会更新线路的。实际上,我没有测试它,但您遇到的问题是,
sbt
在您的映像中不存在。现在更好了,但我得到了
步骤10/11:运行sbt compile--->在66ec059d2144/usr/share/sbt/bin/sbt-launch-lib中运行。bash:line 262:java:command未找到复制运行时jar的命令。mkdir:无法创建目录“”:没有这样的文件或目录/usr/share/sbt/bin/sbt-launch-lib.bash:第74行:java:command-not-found/usr/share/sbt/bin/sbt-launch-lib.bash:第74行:java:command-not-found
所以我可能需要安装
java
tooYeah我找到了Curius并运行了它。所以同样的答案,你需要安装你的应用程序的所有依赖项。您可能需要使用
运行yum安装-y java-11-openjdk
才能最终运行。非常感谢。我在第一篇博文中添加了解决方案它对您有效吗?我得到了
命令'/bin/sh-c yum install sbt-${sbt_VERSION}.rpm'返回了一个非零代码:1
忘记了
-y
。我会更新线路的。实际上,我没有测试它,但您遇到的问题是,
sbt
在您的映像中不存在。现在更好了,但我得到了
步骤10/11:运行sbt compile--->在66ec059d2144/usr/share/sbt/bin/sbt-launch-lib中运行。bash:line 262:java:command未找到复制运行时jar的命令。mkdir:无法创建目录“”:没有这样的文件或目录/usr/share/sbt/bin/sbt-launch-lib.bash:第74行:java:command-not-found/usr/share/sbt/bin/sbt-launch-lib.bash:第74行:java:command-not-found
所以我可能需要安装
java
tooYeah我找到了Curius并运行了它。所以同样的答案,你需要安装你的应用程序的所有依赖项。您可能需要使用
运行yum安装-y java-11-openjdk
才能最终运行。非常感谢。我在第一篇文章中添加了解决方案