简体   繁体   English

为Spring Cloud Config Server创建Docker文件

[英]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: 这些是我遵循的步骤:

  • Open https://start.spring.io/ and added config-server as a dependancies. 打开https://start.spring.io/并添加config-server作为依赖项。 then downloaded the project. 然后下载该项目。
  • Added @EnableConfigServer annotation in demo\\src\\main\\java\\com\\example\\demo\\DemoApplication.java demo\\src\\main\\java\\com\\example\\demo\\DemoApplication.java添加了@EnableConfigServer批注
  • Added below code in 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.

相关问题 Spring 云配置服务器不适用于 Docker 构建 - Spring Cloud Config Server doens't work with Docker build 带有配置服务器的 Spring Cloud Eureka - Spring Cloud Eureka with Config Server 我可以在Spring Cloud Config Server中托管JSON文件吗? - Can I host JSON file in Spring Cloud Config Server? Spring 云配置服务器无法读取属性文件 - Spring cloud config server not able to read property file Spring 作为 Docker 容器启动时,启动服务无法连接到 Spring 云配置服务器 - Spring Boot service can't connect to Spring Cloud Config Server when start as a Docker container java - 如何在java spring中将propertysource设置为从云配置服务器获取的配置文件? - How to set propertysource to config file fetched from cloud config server in java spring? Spring 启动微服务 - 配置服务器无法在 Docker 中获取属性文件(添加属性源:配置资源) - Spring Boot Microservices - Config Server cannot fetch property file (Adding property source: Config resource) in Docker 当 Spring Security 在 Spring Cloud Config Server 上处于活动状态时,Spring Cloud Config Client 不获取配置 - Spring Cloud Config Client not fetching config when Spring Security is active on Spring Cloud Config Server 配置Spring Cloud Config Server和Spring Cloud Vault以进行生产 - Configuring Spring Cloud Config Server and Spring Cloud Vault for production 在 Spring 引导应用程序中使用 Spring 云配置服务器从 Bitbucket 存储库读取外部 YAML/JSON 文件 - Reading an external YAML/JSON File from Bitbucket Repository using Spring Cloud Config Server in a Spring Boot Application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM