'Running docker container of spring boot project, file declared in application.yml is not found

At a spring boot application, at application.yml I have defined a file path for the logback configuration. It is found and taken into account correctly when running the app.

logging:
  config: src/main/resources/config/logback-spring.xml

and when i run the created image i get the following error

Logging system failed to initialize using configuration from 'src/main/resources/config/logback-spring.xml'
java.io.FileNotFoundException: 
/workspace/src/main/resources/config/logback-spring.xml (No such file or directory)                                                   at java.base/java.io.FileInputStream.open0(Native Method)   

Docker runs the /workspace/ path that messes up the build. (same happens if i run with docker run or with docker-compose up)

The app runs fine from maven or intellij or jar file.

What am I missing ? Addittional info can be provided if asked in the comments



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source