kiki keke
kiki keke

Reputation: 119

java how externalise application.properties from my war file

I was asked to externalize my properties file from my wars file and gave a file an external path, because I have a docker image with a tomcat Inside and I was asked to master the files outside my docker.

how to do that?

I already know how to modify the pom to exclude my file from the build.

Upvotes: 0

Views: 130

Answers (1)

sapan prajapati
sapan prajapati

Reputation: 1734

You can mount a volume in docker container to a path in host machine. Now when you create any application.properties file on host machine path, same will be visible and accessible to docker container as well.

Below is the plain docker run command to achieve it.

docker run -it --rm -v /home/k/myDocker:/k busybox sh

Below is the docker-compose.yml approach

version: '3'

services:
  prometheus:
    image: prom/prometheus
    volumes:
      - prometheus-data:/prometheus

volumes:
  prometheus-data:
    driver: local
    driver_opts:
      o: bind
      type: none
      device: /disk1/prometheus-data

Upvotes: 1

Related Questions