2

I'd like to develop a rails app using docker so I don't have to install a database locally. Therefore I created the following basic example (new rails app):

https://gist.github.com/solars/62eeae2f86ab6ec3fa35

As you can see there is a problem with the bundler environment, can anyone tell me how to fix this?

Usually the Gemfile is copied over in the Dockerfile - but I think this is not necessary if mounting the app in a volume, is this right? (Most of the examples are using ADD or COPY for either the Gemfile or the app, but as I'm developing, I'd like to avoid that so I can always change things.

I also thought that something like docker-compose run app echo $PATH should return the $PATH in my container, but it seems to be the same as my local path? Same with echo $RAILS_ENV which returns nothing, although it's set in the compose file..

Solution: The container of course does not persist the bundled gems, that was the problem. So the solution is to either bundle in the Dockerfile, or have the gems in the app directory which is shared as a volume.

chbla
  • 357
  • 1
  • 4
  • 11

1 Answers1

3

docker-compose run app echo $PATH will always return your local path, as the environment variable is interpreted by the local shell.

This would work better:

docker-compose run app sh -c 'echo $PATH' 

Regarding rails, check "Rails 4 bundler: command not found: rails"

A bundle exec rake rails:update:bin might help (for instance, as a RUN directive in your Dockerfile).

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 2
    The problem was that of course with run, if I don't persist the gems, they are not stored. So I need to bundle in the Dockefile already OR store the bundled gems in the application directory. Thanks a lot for the hint for the shell! – chbla Dec 18 '15 at 08:30