Hello,
I’m a new Docker user. I need to do the following:
- Compile and run a random user’s C++ program on my machine (along with my own additions to their code)
- Capture the output and process it locally.
I’m running docker on an Amazon AWS Linux micro instance. I did the following:
-
Customized and built an Ubuntu image called sandbox which has all the packages I need (g++, valgrind, make, etc.)
-
In a different directory which contains my pre-req files, I copy over the user’s files. Then I build a new docker image from this directory which builds using the sandbox base image. My Docker file says:
FROM sandbox
COPY . /sandbox
RUN make
Then I run a Docker build command from my local environment as follows:
307 {aws-028}testcpp: docker build --tag=test .
Sending build context to Docker daemon 35.33kB
Step 1/5 : FROM sandbox
---> 42fdf2be6912
Step 2/5 : MAINTAINER AVFILT
---> Running in d5531528333c
Removing intermediate container d5531528333c
---> 561070a04095
Step 3/5 : WORKDIR /sandbox
---> Running in 7d1afb32f3ef
Removing intermediate container 7d1afb32f3ef
---> e416508e5180
Step 4/5 : COPY . /sandbox
---> 8392a378a6a2
Step 5/5 : RUN make
---> Running in bf041f3a5353
g++ -Wall -O0 -std=c++0x *.cpp
valgrind ./a.out # >a.log 2>&1
==22== Memcheck, a memory error detector
==22== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==22== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==22== Command: ./a.out
==22==
Success. All tests passed. Congratulations.
==22==
==22== HEAP SUMMARY:
==22== in use at exit: 72,704 bytes in 1 blocks
==22== total heap usage: 3,881 allocs, 3,880 frees, 524,711 bytes allocated
==22==
==22== LEAK SUMMARY:
==22== definitely lost: 0 bytes in 0 blocks
==22== indirectly lost: 0 bytes in 0 blocks
==22== possibly lost: 0 bytes in 0 blocks
==22== still reachable: 72,704 bytes in 1 blocks
==22== suppressed: 0 bytes in 0 blocks
==22== Rerun with --leak-check=full to see details of leaked memory
==22==
==22== For counts of detected and suppressed errors, rerun with: -v
==22== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Removing intermediate container bf041f3a5353
---> 9cf23028b470
Successfully built 9cf23028b470
Successfully tagged test:latest
I capture the above output into a local file and then process it using a script.
My question: Is this the best way to accomplish what I want (essentially the output of make and valgrind)?
If I do this iteratively a number of times, can I assume that each run will not leave behind dangling data to be cleaned up (and eventually run out of disk space)?
Thank you very much,
&