Configure command to be run inside a docker container in docker compose

My company is switching to docker for our dev and prod environments. We use docker compose on local machines.
We have a few things we need to run inside the docker container during development, like clearing the cache, resetting the database etc.

To make it easier for our designers and hide some projects specific differences i would like to use something like npm-run-scripts. What would be the best way to solve this with docker?

Source: StackOverflow