[英]Create docker file for spring cloud config server
I am trying to build docker image for my config server. 我正在尝试为我的配置服务器构建docker映像。 These are the steps which I have followed:
这些是我遵循的步骤:
@EnableConfigServer
annotation in demo\\src\\main\\java\\com\\example\\demo\\DemoApplication.java
demo\\src\\main\\java\\com\\example\\demo\\DemoApplication.java
添加了@EnableConfigServer
批注 demo\\src\\main\\resources\\application.properties
demo\\src\\main\\resources\\application.properties
添加了以下代码 server.port=8888 spring.cloud.config.server.git.uri=https://github.com/mygitusername/configserverdata.git
When I started config server using command mvn spring-boot:run
on local, It's working fine. 当我在本地使用命令
mvn spring-boot:run
启动配置服务器时,它工作正常。
Now I want to create docker image for my config server. 现在,我想为我的配置服务器创建docker镜像。 for this I get this docker file from here .
为此,我从这里获得了这个docker文件。
FROM maven:alpine
MAINTAINER hyness <hyness@freshlegacycode.org>
EXPOSE 8888
COPY . /Demo/
WORKDIR /Demo/
RUN mvn package
VOLUME /config
WORKDIR /
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar",\
"/Demo/target/Demo.jar",\
"--server.port=8888",\
"--spring.config.name=application"]
When I execute docker build -t spring-cloud-config-server .
当我执行
docker build -t spring-cloud-config-server .
it says BUILD Failure with this reason 它说BUILD失败是因为这个原因
The goal you specified requires a project to execute but there is no POM in this directory (/demo).
您指定的目标需要一个项目来执行,但是此目录(/ demo)中没有POM。 Please verify you invoked Maven from the correct directory.
请验证您是否从正确的目录中调用了Maven。
Please help me to create correct docker file for my config server. 请帮助我为我的配置服务器创建正确的docker文件。
It might be a silly question, But I need to specify mvn spring-boot:run
in Dockerfile as well. 这可能是一个愚蠢的问题,但是我还需要在Dockerfile中指定
mvn spring-boot:run
。
I've just started learning docker. 我刚刚开始学习docker。
I have just built the application and it works fine with this Dockerfile and dirs layout (have alook at "COPY ./demo /demo/") : 我刚刚构建了该应用程序,并且可以在此Dockerfile和dirs布局中正常工作(请查看“ COPY ./demo / demo /”):
FROM maven:alpine
MAINTAINER hyness <hyness@freshlegacycode.org>
EXPOSE 8888
COPY ./demo /demo/
WORKDIR /demo/
RUN mvn package
VOLUME /config
WORKDIR /
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar",\
"/demo/target/demo.jar",\
"--server.port=8888",\
"--spring.config.name=application"]
$ tree
.
├── demo
│ ├── pom.xml
│ └── src
│ └── main
│ ├── java
│ │ └── com
│ │ └── example
│ │ └── demo
│ │ └── DemoApplication.java
│ └── resources
│ └── application.properties
└── Dockerfile
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.