I am writing a Python Django web application which is currently deployed on Heroku. For certain kinds of requests, I want to run a docker container in an isolated environment. For example, one of my API endpoints looks like this:
import docker
def post(request):
# do some work here...
client = docker.from_env()
client.containers.run('some-image', 'some command')
# format and return response here...
How can I setup my Heroku application so that I can create and run docker containers like this from within my web application? I have tested everything locally and verified that it works. All I need is to deploy this to Heroku.