Search code examples
pythonvirtual-machinesandboxlxc

How to build a web service with one sandboxed Python (VM) per request


As part of an effort to make the scikit-image examples gallery interactive, I would like to build a web service that receives a Python code snippet, executes it, and provides me with the generated output image.

For safety, the Python instances launched should be sandboxed and resource controlled, so I was thinking of using LXC containers.

Is this a good way to approach the problem? If so, what is the recommended way of launching one Python VM per request?


Solution

  • Stefan, perhaps "Docker" could be of use? I get the impression that you could constrain the VM that the application is run in -- an example web service:

    http://docs.docker.io/en/latest/examples/python_web_app/

    You could try running the application on Digital Ocean, like so:

    https://www.digitalocean.com/community/articles/how-to-install-and-use-docker-getting-started