简体   繁体   English

Docker 无法在没有 docker-compose 的情况下访问 jar 文件

[英]Docker unable to access jar file without docker-compose

as far as I know I only got this answer for my query, but unfortunately I do not have docker-compose.yml I am just trying with plain Dockerfile below is my dockerFile.据我所知,我的查询只得到了这个答案,但不幸的是我没有 docker-compose.yml 我只是在尝试使用普通的 Dockerfile 下面是我的 dockerFile。

FROM openjdk:8-jre-alpine
VOLUME /tmp
ARG JAR_FILE
COPY ${JAR_FILE} ebiPorjectJava.jar
ENTRYPOINT ["java","-jar","/ebiProjectJava.jar"]

but build is getting successful, by below command.但是通过以下命令构建成功。

docker build -t ebiproject .

but when I am trying to run the docker it says unable to access jar file但是当我尝试运行 docker 时,它说无法访问 jar 文件

docker run -p 3000:3000 ebiproejct

but it says unable to access jar但它说无法访问 jar 在此处输入图像描述

I am running docker on windows and I have spring boot application to run我在 windows 上运行 docker 并且我有 spring 启动应用程序要运行

I updated with below one:我更新了以下一个:

FROM openjdk:8-jre-alpine
VOLUME /tmp
ARG JAR_FILE
COPY ${JAR_FILE} /ebiProjectJava.jar
ENTRYPOINT ["java","-jar","/ebiProjectJava.jar"]

but now I am getting corrupted error:但现在我收到损坏的错误: 在此处输入图像描述

ARG JAR_FILE ARG JAR_FILE

expects you to pass the path of the jar_file as docker run argument希望您将 jar_file 的路径作为 docker 运行参数传递

Otherwise nothing will be copied to the place, thus java jar won't be able to run the jar.否则不会将任何内容复制到该位置,因此 java jar 将无法运行 jar。

Check this out: https://vsupalov.com/docker-env-vars/看看这个: https://vsupalov.com/docker-env-vars/

In this situation you can go in your container with this command:在这种情况下,您可以使用以下命令在容器中 go:

docker run --rm -it <container_name> <image_name> <command>

you can use bash , ash or sh as您可以使用bashashsh作为

and after entering the container, you can check, run, or any tests in that.进入容器后,您可以在其中进行检查、运行或任何测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM