I have a problem with my Spring Boot project running on docker container. Scheduled task doesn't work if I run container as demonized ( docker run -d). When I run image non in background everything is working. Unfortunately, I have to run it as demonized and i have no idea how to resolve that problem. Thank you for any solution :)
My Scheduled annotation:
@Scheduled(fixedDelay = 1440000)
This is my Dockerfile:
FROM java:openjdk-8
ENV SPRING_PROFILES_ACTIVE dev,docker
WORKDIR /app
EXPOSE 9000 9000
RUN apt-get update && apt-get -y install cron
RUN service cron start
COPY build/libs/app.jar /app/app.jar
CMD ["/bin/sh", "-c", "java -jar /app/app.jar --spring.profiles.active=$SPRING_PROFILES_ACTIVE"]