spring boot+spring cloud 集成docker基本文件配置

1. 在pom.xml中加入依赖插件,配置dockerfile文件位置,生成docker镜像的名字,要往哪个ip上发布镜像,构建的jar包的名字


web


org.springframework.boot
spring-boot-maven-plugin


com.spotify
docker-maven-plugin
${docker.plugin.version}


package

build




http://IP地址:端口号
${docker.image.prefix}/${project.artifactId}
${project.basedir}/src/main/docker


/
${project.build.directory}
${project.build.finalName}.jar






2.在配置好的dockerfile文件设置一些镜像基本信息,需要的基础镜像,把jar包挂载到哪个目录下,时区,非阻塞发生器等。

FROM livingobjects/jre8

VOLUME /tmp

ADD web.jar web.jar

ENV TZ=Asia/Shanghai

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

3. docker-compose文件放到root目录下,打docker-composeup -d 指令启动所有镜像

配置启动的微服务名、要暴露的端口号、时区、link关系等

version: "3"

services:

 eureka:

   image: eureka

   ports:

     - 8761:8761

   volumes:

     - /etc/localtime:/etc/localtime:ro

   environment:

     - TZ=Asia/Shanghai

  web:

   image: web

   ports:

     - 8000:8000

   links:

     - eureka

   volumes:

     - /etc/localtime:/etc/localtime:ro

   environment:

     - TZ=Asia/Shanghai

  web-ui:

   image: web-ui

   ports:

     - 8001:8001

   links:

     - eureka

   volumes:

     - /etc/localtime:/etc/localtime:ro

   environment:

     - TZ=Asia/Shanghai

 

你可能感兴趣的:(spring boot+spring cloud 集成docker基本文件配置)