Running tests without ssh’ing into my container

I have a Python API in a docker container, but I want to be able to run tests without sshing in and running the command, but I’m not really sure how I can do that via the command line. For example, I know to ssh in I do (via a script so I can ssh into any of my three containers):

docker exec -it gp-api ash

but when I want to run tests, I need to ssh in, go up a folder, and then run pytest. Not sure how to do that all from the docker command line.

Source: StackOverflow