From https://docs.docker.com/engine/reference/builder/#cmd:
If you would like your container to run the same executable every time, then you should consider using ENTRYPOINT in combination with CMD. See ENTRYPOINT
https://docs.docker.com/engine/reference/builder/#entrypoint
tl;dr
You could define an entrypoint
under app and define a bash file there:
app:
entrypoint: [bin/entry]
..
bin/entry file example:
#!/bin/bash
set -e
rake db:create
rake db:migrate
exec "$@"