简体   繁体   English

Docker:从Web UI用户到Docker的输入,运行Python解释器

[英]Docker: input from web UI user to Docker run Python interpreter

I am trying to make a web application that automatically grades python code supplied by programming students. 我正在尝试制作一个网络应用程序,该程序可以自动为编程学生提供的python代码评分。 I have planned to interpret the code in a Docker instance as a means of sandboxing but now I've hit a problem. 我计划将Docker实例中的代码解释为沙盒的一种方法,但现在遇到了一个问题。 What if a student writes input("...") in their code? 如果学生在他们的代码中写input(“ ...”)怎么办? This will leave the python interpreter inside the Docker waiting for additional input. 这将使Docker内部的python解释器等待其他输入。 The docker container will eventually get killed if it doesn't finish within some time but I would actually want to offer the oppurtunity for the students to give input to their programs. 如果Docker容器在一段时间内未完成,最终将被杀死,但我实际上想为学生提供输入程序的机会。 I know I could start the Docker in interactive mode but then the problem is: 我知道我可以以交互方式启动Docker,但是问题是:

How could docker let my webservice know that the web UI user should be prompted for input? 泊坞窗如何让我的Web服务知道应提示Web UI用户输入?

You might want to look at the wetty project. 您可能要看一下wetty项目。 You could provide an actual bash (or other shell, iptyhon?) prompt where they could interact with the prompt from the convenience of their web browser. 您可以提供一个实际的bash(或其他shell,iptyhon?)提示,在这里他们可以通过其Web浏览器的便利与提示进行交互。

There are several pre-made dockerfiles to go by as examples: https://registry.hub.docker.com/search?q=wetty 有几个预制的dockerfile作为示例: https ://registry.hub.docker.com/search?q = wetty

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM