简体   繁体   English

从 Docker 运行 Spring Boot 应用程序不起作用

[英]Running a Spring Boot app from Docker is not working

I have a rather strange problem.我有一个比较奇怪的问题。 I am trying to run a Spring Boot app via docker.我正在尝试通过 docker 运行 Spring Boot 应用程序。 So here are my steps.所以这是我的步骤。

1) I am creating a Dockerfile. 1) 我正在创建一个 Dockerfile。

FROM centos

RUN yum install -y java

VOLUME /tmp
ADD /spring-boot-web-0.0.1-SNAPSHOT.jar myapp.jar
RUN sh -c 'touch /myapp.jar'
ENTRYPOINT [“java","-Djava.security.egd=file:/dev/./urandom","- 
jar","/myapp.jar"]

In this file I am installing java.在这个文件中,我正在安装 java。 I am also using the jar file of the app called spring-boot-web-0.0.1-SNAPSHOT.jar我也在使用名为spring-boot-web-0.0.1-SNAPSHOT.jar的应用程序的 jar 文件

2) The next step is to build an image. 2) 下一步是构建镜像。 So I am typing所以我正在打字

tmp theodosiostziomakas$ docker build -t spring-boot-docker .

截图 1

So the image was built correctly.所以图像构建正确。

3) Now I am running that image to generate a container. 3)现在我正在运行该图像以生成一个容器。 So所以

docker run -d -p 8080:8080 spring-boot-docker

截图 2

You can see that a container is generated.可以看到生成了一个容器。 But when I type但是当我输入

$ docker ps

the container_id is not visible and when I type localhost:8080 in the browser the app is not running at all. container_id 不可见,当我在浏览器中输入localhost:8080 时,应用程序根本没有运行。 Why is this happening?为什么会这样? Any ideas?有任何想法吗? How to fix it?如何解决?

If the posted Dockerfile the file you are using then there is a wrong quote sign just before java:如果发布的 Dockerfile 是您正在使用的文件,那么在 java 之前有一个错误的引号:

FROM centos

RUN yum install -y java

VOLUME /tmp

ADD /spring-boot-web-0.0.1-SNAPSHOT.jar myapp.jar

RUN sh -c 'touch /myapp.jar'

ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/myapp.jar"]

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

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