#Java Spring Boot app not auto-restarting when using Docker

1 messages ยท Page 1 of 1 (latest)

acoustic notchBOT
#

<@&987246554085740594> please have a look, thanks.

#

Here is an AI assisted attempt to answer your question ๐Ÿค–. Maybe it helps! In any case, a human is on the way ๐Ÿ‘. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#
TJ-Bot
I am having troubles when using Docker when in my Spring Boot app in my container, docker is not restarting the server once I make any file changes to my classes!

The issue here is that Docker containers are isolated environments, and they do not automatically detect file changes on your host machine unless you explicitly mount your source code directories as volumes inside the container. Without this, the container only runs the code baked into the image at build time, so changes on your host will not reflect or trigger a restart.

Key points to check:

  • Volume mounting: Ensure you are mounting your project directory into the container with -v $(pwd):/app (or equivalent) so changes reflect inside.
  • Spring Boot devtools: Include spring-boot-devtools dependency; it triggers restarts on classpath changes.
  • Run in development mode: Your app inside the container must be running in a way that listens for file changes (e.g., via spring-boot-devtools or by running via mvn spring-boot:run inside the container).
  • Dockerfile CMD: Avoid packaging a fat jar and running it directly if you want live reload; instead, run the app in its source form or use hot reload tools.
  • File sync latency: On some OSes (Windows/Mac), Docker's file sync can have delays or caching issues messing with live reload.

Useful links: