nickjj / docker-rails-example

A production ready example Rails app that's using Docker and Docker Compose.
MIT License
942 stars 185 forks source link

use `run` instead of `exec` as `DC` for rails in run script? #27

Closed prognostikos closed 2 years ago

prognostikos commented 2 years ago

I ran into a problem running rails generators with the run script via e.g. ./run rails g model MyModel my_attr. There was no output from the command and no changes were made.

Adding DC=run inside the rails function fixes it for me - it seems docker-compose exec won't work with the generators while docker-compose run does.

I'm not sure if this should be a default or not but thought I'd mention it in case anyone else runs into the problem.

prognostikos commented 2 years ago

Ah, of course, it was because at the time I didn't have the web container running so there was no web container to exec inside of. So maybe not necessary after all.

nickjj commented 2 years ago

Correct, you can keep it as the default exec, but the container needs to be running already which would likely be the case if you're actively developing the project and have things up and running.