|
| 1 | +--- |
| 2 | +title: Custom Docker Imagegs |
| 3 | +category: Instructor > Autograding |
| 4 | +--- |
| 5 | + |
| 6 | +Some assignments may require specific languages, packages, libraries, etc. |
| 7 | +We can't install all of these different requirements on the base system. |
| 8 | +We offer the ability to use custom Docker images for autograding. |
| 9 | +We pull images from Dockerhub and allow you to run any command inside |
| 10 | +that container. Below are steps to make your own or edit an image: |
| 11 | + |
| 12 | +1. Create a Dockerfile or fetch an existing one |
| 13 | + |
| 14 | + If this is a new Dockerfile, choose a base image. |
| 15 | + We recommend you choose the same base image as your system OS (i.e. ubuntu:22.04) |
| 16 | + but you could, in theory, pick any base image you want. |
| 17 | + |
| 18 | +2. Add any packages, libraries, languages, etc that you need |
| 19 | + |
| 20 | +3. Build your image locally |
| 21 | + |
| 22 | + Run the following in the directory containing the Dockerfile. |
| 23 | + Replace `NAME` with a tag name you would like for your Docker image. |
| 24 | + ``` |
| 25 | + docker build -t NAME . |
| 26 | + ``` |
| 27 | +
|
| 28 | +4. Test your image locally |
| 29 | +
|
| 30 | + Run the following to enter a bash shell inside your container: |
| 31 | + ``` |
| 32 | + docker run --rm -it NAME bash |
| 33 | + ``` |
| 34 | +
|
| 35 | + Verify that you can call any specific commands you want to on Submitty. |
| 36 | +
|
| 37 | +5. Push your tag to Dockerhub |
| 38 | +
|
| 39 | + First you need to tag your image in the proper format for Dockerhub. |
| 40 | + An example would be `submitty/autograding-default:latest`. |
| 41 | + ``` |
| 42 | + docker image tag NAME USERNAME/REPONAME:TAGNAME |
| 43 | + ``` |
| 44 | +
|
| 45 | + Next you need to push it to Dockerhub. If you have not logged into Docker on your CLI then run: |
| 46 | + ``` |
| 47 | + docker login |
| 48 | + ``` |
| 49 | +
|
| 50 | + Finally, push the image: |
| 51 | + ``` |
| 52 | + docker push USERNAME/REPONAME:TAGNAME |
| 53 | + ``` |
| 54 | +
|
| 55 | + _NOTE: At RPI, we maintain a [GitHub repo](https://github.com/Submitty/DockerImagesRPI) |
| 56 | + to automate this process when Dockerfiles are updated in the correct location in the repo._ |
| 57 | +
|
| 58 | +6. Add the Docker image to Submitty via the Docker UI |
| 59 | +
|
| 60 | + Click [here](/instructor/autograding/docker_ui) to learn more about how to do this. |
| 61 | +
|
| 62 | +7. In your autograding `config.json`, specify this new image. |
| 63 | +
|
| 64 | + In the root level of your JSON object, add: |
| 65 | + ``` |
| 66 | + "autograding_method": "docker", |
| 67 | + ``` |
| 68 | +
|
| 69 | + You also need to choose your specific image which there are 2 ways to do this. |
| 70 | +
|
| 71 | + You can specify an image at the root level which will apply to all test cases. |
| 72 | + Add the following to the root level of your JSON object: |
| 73 | + ``` |
| 74 | + "container_options": { |
| 75 | + "container_image": "IMAGE_NAME" |
| 76 | + }, |
| 77 | + ``` |
| 78 | + Replace `IMAGE_NAME` with your full image tag you added to the Docker UI. |
| 79 | + Once this is complete, you can specify the command you want to be run. |
| 80 | +
|
| 81 | + Another way this can be done is by specifying the image at each test case. |
| 82 | + See [Networked Containers](/instructor/autograding/networking) for more on this. |
| 83 | +
|
0 commit comments