Use run everytime or use bash and do commands inside?

I have a rails project and I’m testing it with rspec. Usually, I use spring that autoload files and I a launch a test, for exemple, like this :

bin/rspec spec/requests/messages_spec.rb

I can run it docker by doing this :

docker-compose run web bin/rspec spec/requests/messages_spec.rb

Or I can use bash like this :

docker-compose run web bash
bin/rspec spec/requests/messages_spec.rb

I think there is pro and cons for both, here is what I can see :

  • Run everytime :

  • pros

    • I still in my host shell. I can use my zsh and .zshrc
    • I think it’s the docker way
  • cons

  • It’s longer to write even if did an alis (dcr instead of docker-compose run)

  • It’s longer to run. Spring is not useful in this case.

  • Bash :

  • pros

    • faster
    • simpler
  • cons

    • I have to copy my dotenv files if I want to use them and reinstall my favourite tools.

What do you do? How do you use docker in development?