How do I execute dynamic code in a container?

11/22/2019

I'm working on a personal project involving a browser-based code editor (think https://repl.it). My plan:

1) Constantly stream the code being written to a remote docker volume on kubernetes.

2) Execute this code when the user presses "run".

I've already started working on the streaming infrastructure, and have a good grasp on how I'd like to do it. Regarding the code execution, however, I'm in need of some guidance.

Idea A: I was thinking that I could have two docker containers, one web server and one "environment", sitting on the same VM. When a request would come into the webserver, it would then run a docker exec ... on the environment.

Idea B: I use kubectl, specifically kubectl exec to execute the code on the container.

A few things to note. I want to make the "environment" container interchangeable, that is, my app should be able to support python, js, etc.. Any thoughts?

-- Jay K.
containers
docker
docker-exec
kubectl
kubernetes

1 Answer

11/22/2019
  1. THIS IS A VERY BAD IDEA DO NOT DO IT
  2. You would want to run each snippet in a new container for maximum isolation.
-- coderanger
Source: StackOverflow