If the time such as created_at and datetime is not saved in Japan time with Docker and Rails, check the timezone in the ruby container.
If you write it in config like this, a lot will come out. This seems to work if the environment is homebrew.
With docker, it is necessary to set the timezone in the container to Asia/Tokyo.
config/application.rb
module App
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2
config.time_zone = 'Asia/Tokyo'
config.active_record.default_timezone = :local
So add this.
ruby Dockerfile
ENV TZ Asia/Tokyo <=Add here(docker-comopse.yml may be better)
If this doesn't work, you may need to check the timezone of the DB container and set it to'Asia/Tokyo'.
Reference page Change the Docker container timezone setting -Box programming diary.
Check TZ when Time \ .now is not Japan time in Rails \ | TOMILOG
Differences between Time, Date, DateTime, TimeWithZone between Ruby and Rails -Qiita
MySQL :: MySQL 5 \ .6 Reference Manual :: 10 \ .6 Time Zone Support on MySQL Server
Recommended Posts