简体   繁体   中英

Can't mount application.yaml into docker java 8 spring

Can someone explain me, why it doesn't mounted and java don't read application.yaml?

This is my dockerfile:

FROM openjdk:17-jdk-slim
WORKDIR /app
COPY build/libs/Notify-2.0-all.jar app.jar
COPY src/main/resources/application.yaml resources/application.yaml
ENTRYPOINT ["java", "-jar", "app.jar"]

and this is docker compose

version: '3.7'
services:
  discord-bot-cyberdawn-boosty:
    image: discord-bot-v2
    volumes:
      - type: bind
        source: ./application.yaml
        target: /app/resources/application.yaml

I tried ${pwd} but it still doesn't work.

I also tried this

FROM openjdk:17
WORKDIR /app
COPY build/libs/Notify-2.0-all.jar app.jar
COPY src/main/resources/application.yaml /app/application.yaml
CMD ["java", "-jar", "app.jar", "--spring.config.name=application", "--spring.config.location=file:/app/application.yaml"]
version: '3.9'
services:
  test-bot:
    image: test-bot-v2
    volumes:
      - type: bind
        source: ${PWD}/application.yaml
        target: /app/application.yaml

and it's still doesn't work.

This doesn't work too:

docker run -v /home/bot-v2/cyberdawn/application.yaml:/app/application.yaml test-bot-v2

Jar file cant read application.yaml. I should use war.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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