我正在使用https://sbt-native-packager.readthedocs.io/en/stable/introduction.html来构建我的Scala应用程序,并希望将该应用程序发布为本地docker容器。
我输入了以下命令:
sbt docker:publishLocal
我认为,一切都很好,并且生成了一个图像:
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
sapmock 0.1 db261ab225b5 About a minute ago 664MB
<none> <none> 0940c75d8e5a About a minute ago 703MB
openjdk 8 bec43387959a 10 days ago 625MB
为什么sbt
创建图像<none>
?
当我将图像作为容器运行时,它立即停止:
~/scala/sapmock$ docker run -d -p 8080:80 sapmock:0.1
91abf0e00e3a46baa78a09b9eccd3c562ae82d5b058d5e122e8927f8e7307afd
~/scala/sapmock$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
91abf0e00e3a sapmock:0.1 "/opt/docker/bin/sap…" 10 seconds ago Exited (0) 8 seconds ago upbeat_brattain
~/scala/sapmock$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
为什么?
可在此处找到资源:https://gitlab.com/sweetsoft/sapmock
此外,生成的docker文件的内容:
FROM openjdk:8 as stage0
WORKDIR /opt/docker
COPY opt /opt
USER root
RUN ["chmod", "-R", "u=rX,g=rX", "/opt/docker"]
RUN ["chmod", "u+x,g+x", "/opt/docker/bin/sapmock"]
FROM openjdk:8
USER root
RUN id -u demiourgos728 2> /dev/null || (( getent group 0 || groupadd -g 0 root ) && useradd --system --create-home --uid 1001 --gid 0 demiourgos728 )
WORKDIR /opt/docker
COPY --from=stage0 --chown=demiourgos728:root /opt/docker /opt/docker
EXPOSE 8080
USER 1001:0
ENTRYPOINT ["/opt/docker/bin/sapmock"]
CMD []