I'm getting an error as follows:
#8 46.51 [error] java.lang.IllegalStateException: cannot run sbt from root directory without -Dsbt.rootdir=true; see sbt/sbt#1458
#8 46.51 [error] Use 'last' for the full log.
The Dockerfile is mostly just downloading and installing the debian. But something is making sbt unhappy. Not sure what it is.
FROM openjdk:8 as build
ENV SBT_VERSION "1.5.8"
ENV APP_HOME /service
# Install sbt
RUN \
curl -L -o sbt-$SBT_VERSION.deb https://repo.scala-sbt.org/scalasbt/debian/sbt-$SBT_VERSION.deb && \
dpkg -i sbt-$SBT_VERSION.deb && \
rm sbt-$SBT_VERSION.deb && \
apt-get update && \
apt-get install sbt && \
sbt sbtVersion
CodePudding user response:
I believe the issue is using root aka / as the working directory. Adding WORKDIR /home before the RUN ... command fixes the docker build ... error and I was able to docker run ... successfully.
docker build ...
docker build -f Dockerfile.so -t 70625015:latest .
[ ] Building 69.4s (7/7) FINISHED
=> [internal] load build definition from Dockerfile.so 0.0s
=> => transferring dockerfile: 387B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/openjdk:8 0.0s
=> CACHED [1/3] FROM docker.io/library/openjdk:8 0.0s
=> [2/3] WORKDIR /home 0.0s
=> [3/3] RUN curl -L -o sbt-1.5.8.deb https://repo.scala-sbt.org/scalasbt/debian/sbt-1.5.8.deb && dpkg -i sbt-1.5 68.3s
=> exporting to image 0.9s
=> => exporting layers 0.9s
=> => writing image sha256:99e90196e9a6b2d768adf4e6a01883785847758a5f136f4a858a636e60b77819 0.0s
=> => naming to docker.io/library/70625015:latest 0.0s
docker run .... launching to an sbt console.
(:|✔)$ docker run -it 70625015:latest
root@3a1084220dc9:/home#
CodePudding user response:
By the look of the error your getting try adding before the RUN command
the end result will be
FROM openjdk:8 as build
ENV SBT_VERSION "1.5.8"
ENV APP_HOME /service
WORKDIR /app
# Install sbt
RUN \
curl -L -o sbt-$SBT_VERSION.deb https://repo.scala-sbt.org/scalasbt/debian/sbt-$SBT_VERSION.deb && \
dpkg -i sbt-$SBT_VERSION.deb && \
rm sbt-$SBT_VERSION.deb && \
apt-get update && \
apt-get install sbt && \
sbt sbtVersion
