Multi environment configuration of springboot under docker

1. Dockerfile build file defines parameters

FROM java:8
VOLUME ["/home/pdsstm/uploads/pdsfile"]
COPY pds-stm-management.jar /home/pds-stm/jar/pds-stm-management.jar
ENV CE=$CE
EXPOSE 31080
ENTRYPOINT [ "sh", "-c", "java  -Djava.security.egd=file:/dev/./urandom -jar /home/pds-stm/jar/pds-stm-management.jar --spring.profiles.active=$CE" ]

Define variable CE
2. Go to the folder to build the image

docker build -t pds-stm .

3. Run the image with parameters

docker run -d -p 38082:31080 --name pds-stm -e CE="test" -v /home/pds-stm/jar:/home/pds-stm/jar -v /home/pds-stm/logs:/logs  --restart=always pds-stm

 

Read More: