【发布时间】:2020-05-16 10:39:26
【问题描述】:
我想在我的docker 图像中添加 sbt。我基于centos:centos8 图像创建了Dockerfile:
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的可执行文件。仅仅下载一个 jar 文件是不行的。
标签: docker centos sbt dockerfile