Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to persist sessions of spring boot application running on tomcat inside docker

I have a standart Dockerfile for my spring boot(2.2) app

FROM openjdk:11-slim
EXPOSE 8080
COPY ./build/libs/*.jar ./app.jar
CMD java -jar app.jar

There is an property in spring boot to enable session persistence (in my case on Tomcat)

server.servlet.session.persistent=true

Using redis seems like an overkill for my one-service application.

Maybe I can create a volume to store sessions?

like image 642
Dennis Gloss Avatar asked Sep 03 '25 02:09

Dennis Gloss


1 Answers

Simply define the directory:

server.servlet.session.store-dir=/<the directory you mount as volume>

That's it.

like image 198
Simon Martinelli Avatar answered Sep 05 '25 15:09

Simon Martinelli