FROM openjdk:8-jre-alpine ADD target/*.jar app.jar EXPOSE 8080 ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
使用 ENTRYPOINT ,可在 Docker 命令后面添加额外参数,
比如 --server.port=8888 等等
不同环境、不同应用创建不同的配置
此处用可视化工具来创建是为了更方便的维护配置,当然也可以用命令行来创建,结合实际选择合适的方式。
3、创建服务,依赖配置docker service create --name--config source=dev-spring-boot,target=/application.yaml --publish published=8080,target=8080 --spring.config.location=file:/application.yaml
--config 将 docker config 安装到容器的文件系统,路径 /application.yaml
--spring.config.location=file:/application.yaml 指定 Spring Boot 应用启动使用的配置文件为 /application.yaml
如果要覆盖某个配置项,只需在后面添加 --key=value 即可,示例:
docker service create --name--config source=dev-spring-boot,target=/application.yaml --publish published=8080,target=8080 --spring.config.location=file:/application.yaml --logging.level=debug
作者:Anoyi
链接:https://www.jianshu.com/p/49155f18884c



