0

I need to develop backend for programming competition.

Users submit their codes to the server and we want to run codes in the sandbox, so they won't be able to affect neither the server nor each other.

The question has two parts:

1. Is that correct, that each time I want to score user's solution I need (roughly) to:

#!/usr/bin/python3
c = lxc.Container("apicontainer")
c.create("download", lxc.LXC_CREATE_QUIET, {"dist": "ubuntu",
                                               "release": "trusty",
                                               "arch": "i386"})
c.start()
c.execute('score_solution_script_inside_container')
c.shutdown()
c.destroy()

or c.clone(...)

Well but executing the above mentioned seems to take quite a while, so is it the way or not?

2. Should I use LXC for my purpose or should I use Docker?

I am afraid this question to be put on hold because of this second part, but I've read several SO-questions about the differences between lxc and Docker and it is still confusing for me.

Kamerer
  • 77
  • 1
  • 1
  • 7

1 Answers1

0

Docker shell does this.

Every time you run the dsh command it will spin up a container that you can either use as a shell or provide commands to run. Once you exit, the container is removed.

https://github.com/Solfisk/dsh/blob/master/README.md

mzedeler
  • 4,177
  • 4
  • 28
  • 41