Rails app in docker container doesn't reload in development

dockerize existing rails app
docker rails
docker rails production
rails 6 docker
docker start rails app
docker rails development
docker for rails developers
docker-compose bundle install

I followed this docker-compose tutorial on howto start a rails app. It runs perfectly but the app isn't reloaded when I change a controller.

What can it be missing?

I was struggling with this as well, there are 2 things that you need to do:

1) Map the current directory to the place where Docker is currently hosting the files.

2) Change the config.file_watcher to ActiveSupport::FileUpdateChecker

Step 1:

In your Dockerfile, check where are you copying/adding the files.

See my Dockerfile:

# https://docs.docker.com/compose/rails/#define-the-project

FROM ruby:2.5.0
# The qq is for silent output in the console
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs vim

# Sets the path where the app is going to be installed
ENV RAILS_ROOT /var/www/

# Creates the directory and all the parents (if they don't exist)
RUN mkdir -p $RAILS_ROOT

# This is given by the Ruby Image.
# This will be the de-facto directory that 
# all the contents are going to be stored. 

# We are copying the Gemfile first, so we can install 
# all the dependencies without any issues
# Rails will be installed once you load it from the Gemfile
# This will also ensure that gems are cached and onlu updated when 
# they change.
COPY Gemfile ./
COPY Gemfile.lock ./
# Installs the Gem File.
RUN bundle install

# We copy all the files from the current directory to our
# /app directory
# Pay close attention to the dot (.)
# The first one will select ALL The files of the current directory, 
# The second dot will copy it to the WORKDIR!
COPY . .

The /var/www directory is key here. That's the inner folder structure of the image, and where you need to map the current directory to.

Then, in your docker-compose, define an index called volumes, and place that route there (Works for V2 as well!):

version: '3'
    # Relative path to Dockerfile. 
    # Docker will read the Dockerfile automatically
    build: .
    # This is the one that makes the magic
    - "./:/var/www"

The image above is for reference. Check that the docker-compose and Dockefile are in the same directory. They not necessarily need to be like this, you just have to be sure that the directories are specified correctly.

docker-compose works relative to the file. The ./means that it will take the current docker-compose directory (In this case the entire ruby app) as the place where it's going to host the image's content.

The : just a way to divide between the where it's going to be vs where the image has it.

The next part: /var/www/ is the same path you specified in the Dockerfile.

Step 2:

Open development.rb (Can be found in /config/environments)

and look for config.file_watcher, replace:

config.file_watcher = ActiveSupport::EventedFileUpdateChecker for:

  config.file_watcher = ActiveSupport::FileUpdateChecker

This would do a polling mechanism instead.

That's it!

Remember, that anything that is not routes.rb, and it's not inside the app folder, it's highly probable that the Rails app is going to need to be reloaded manually.

Dockerizing a Ruby on Rails Application, Develop a Rails app in Docker. Docker is a tool which allows developers to define containers for applications; this allows for control If your app does use a JavaScript driver for any tests (I'm using capybara-webkit in the  I have been trying to setup OWASP ZAP scanner for scanning a rails app through CI. The thing is I have a specific script I wish to run (because I run specific user tests on ZAP), so I have my docker container which runs zap as a service: docker run -d --network host --name autozap -u zap -i gmemin/autozap And then execute the following command in CircleCI: docker exec -it autozap python3

Try to rebuild the image with the next command to add the changes to the dockerized app:

docker-compose build

And after it you need to restart the app with docker-compose up to recreate the docker container for your app.

Rails on Docker, create a docker image for the Rails chat application that we created in response from daemon: the Dockerfile (Dockerfile) cannot be empty. Rails is an open-source web application framework written in Ruby.

You should create a volume that maps your local/host source code with the same code located inside docker in order to work on the code and enable such features.

Here's an example of a (docker-compose) mapped file that I'm updating in my editor without having to go through the build process just to see my updates:

    - ./lib/radius_auth.py:/etc/freeradius/radius_auth.py

Without mapping host <--> guest, the guest will simply run whatever code it has received during the build process.

Dockerizing a Rails application, If you are actively developing an application, using Docker can simplify your Containerizing a Ruby on Rails Application for Development with We can also comment out the sqlite gem, since we won't be using it anymore:. Open the Rails console on the app container with docker-compose exec and bundle exec rails console: docker-compose exec app bundle exec rails console At the prompt, inspect the last Shark record in the database: Shark.last.inspect You will see the record you just created:

i got same issue, for someone, i dont know your issue is same mine, but i hope you can fix, for me i could fix when i did that.

1, Restart mac
2, Delete application.yml
3, make
4, make up

Containerizing a Rails Application for Development with Docker , Learn how to move simple Rails applications into Docker. If you already have Docker up and running, you can skip this step and move on to Switching your development environment to Docker does take some amount of  docker-compose.yml. Running our app. Now, we should be able to spin up the dockerized app, with its dependencies. First, we'll need to take care of setting up the database in the new container. Create database: docker-compose run web rake db:create; Run migrations: docker-compose run web rake db:migrate; Run seeds: docker-compose run web rake

Running a Rails Development Environment in Docker, Learn how to add a Docker container to an app to deploy on a server, thus creating a CI process Welcome to the third post in the Ruby on Rails Developer Series. How does the magic happen for development locally? Question: Tag: docker A question came up as I was giving a presentation on Docker to my team that I didn't know how to answer. Many of the prebuilt containers on Docker Hub, for just one example the jboss/wildfly container, are built on top of containers for a specific OS (Ubuntu, CentOS, etc.).

Ruby on Rails Developer Series: Creating a Docker Container , docker run -d -p 3000:3000 my-rails-app $ curl <!DOCTYPE html> <​html> <head> <title>Ruby on Rails: Welcome aboard</title> … What does this  해당 내용은 Docker 공식 사이트에서 실습한 내용을 정리한 내용 입니다. The following are the tutorial of docker official guide below what I have… by jihyunj

How to Deploy a Rails App With Docker Using Official Images , Developing Rails Apps In-Container with Docker Compose them and more transparency for yourself and others looking at your Dockerfile as to what it does. Docker containers share your host’s kernel, and isolation is done using cgroups and other linux kernel libraries. Docker is very lightweight—it typically takes a few milliseconds for a container to start, and running a container doesn’t use much disk space at all. What’s the Bottom Line?

  • There's a number of things that can get in between file system events and your container. Could you add a link to the tutorial or some more info about what you have setup so far.
  • here is the tutorial docs.docker.com/compose/rails, to be more precise I use docker for mac
  • did you find a solution?
  • I already had Step 1 covered, Step 2 fixed this issue for me. This should be the answer.
  • some answer told me 'added volumes'. but i have already volume in docker-compose.Thanks to your answer, i have solved
  • yes, and in Rails you need to add: config.file_watcher = ActiveSupport::FileUpdateChecker to your environment/development.rb
  • or "docker-sync" Please try stop stop once. If you change the branch, it will not be synchronized a lot.