I'm working on a project that automatically compiles, executes and tests the output of submitted programs in C, C++, Java and Python. Obviously this needs to happen inside some sort of secured environments since any kind of code can be submitted. After trying to create the container myself with a chroot jail, which ended up not being practical, I turned to containers.
Now, say I have a C program which takes an
int i as argument, and returns that
i+1. I want to write a script that copies the C program (let's say
plusone.out), together with a list of test inputs (
input.txt) to an LxC container, executes the program inside the container, writes the outputs to a file (
output.txt), and exports that file back to the host system so the main application (that runs outside the container) can check the results. There also need to be some restrictions on the resources, but I can do that with LxC's inbuilt
I know how to do most of the stuff outlined above, but for the life of me I can't find out how to copy files from the host to the container or the other way around. Every tutorial I see demonstrates behavior by running
echo inside the container, but never importing a script or program from the host system. Can anyone help me, or possibly refer me to documentation that can tell me how to accomplish this?