Dennis Gloss
Dennis Gloss

Reputation: 2841

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?

Upvotes: 4

Views: 1313

Answers (1)

Simon Martinelli
Simon Martinelli

Reputation: 36143

Simply define the directory:

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

That's it.

Upvotes: 9

Related Questions