'Rails app inside docker not detecting file changes
I'm running a Rails application inside a docker container. None of my file changes are being detected and auto-reloaded by Rails.
My docker application's main directory is mounted as a docker volume that maps to my host directory. In my docker-compose.yml:
services:
my_app:
# ...
volumes:
- .:/app
My rails app is configured to use ActiveSupport::FileUpdateChecker:
# config/environment/development.rb
config.cache_classes = false
config.reload_classes_only_on_change = true
config.file_watcher = ActiveSupport::FileUpdateChecker
What I've Tried
Inside the Rails framework:
- Here is where the logic is implemented to check if any files are updated. Below that you can also see where it loads the
file_watcher - Here is the implementation of the
FileUpdateChecker, specifically where it checks the maximum updated timestamp (mtime) for each watched path/file
I added print/logging statements inside the Rails gem to see if it was getting called.
When I update a file inside my application, I expect it to be detected by the file watcher but nothing is happening, and nothing gets printed.
Is this expected behavior on docker ? Or is there a way to hot reload while running inside a docker container?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
