Skip to content

Latest commit

 

History

History
148 lines (124 loc) · 7.17 KB

using-docker.md

File metadata and controls

148 lines (124 loc) · 7.17 KB

Tips for Using Docker Containers

Table of Contents

Non-Interactive Docker Commands

Once you have installed Docker Desktop, with MacOS and Linux you can use the following docker run command to start gradle grade as a containerized application, using the DockaGator Docker image available on DockerHub.

docker run --rm --name dockagator \
  -v "$(pwd)":/project \
  -v "$HOME/.dockagator":/root/.local/share \
  gatoreducator/dockagator

The aforementioned command will use "$(pwd)" (i.e., the current working directory) as the project directory and "$HOME/.dockagator" as the cached GatorGrader directory. Please note that both of these directories must exist, although only the project directory must contain something. Generally, the project directory should contain the source code and technical writing for an assignment, as provided to a student by the instructor through GitHub. Additionally, the cached directory should not contain anything other than directories and programs created by DockaGator, thus ensuring that they are not otherwise overwritten during the completion of the assignment.

To ensure that the previous command will work correctly, you should create the cache directory by running the command mkdir $HOME/.dockagator on the MacOS and Linux operating systems. However, if you are using the Windows operating system then you will instead need to type the command mkdir %HomeDrive%%HomePath%/.dockagator. Finally, since the above docker run command does not work correctly on the Windows operating system, you will need to instead run the following command to adapt to the differences in the cmd terminal window:

docker run --rm --name dockagator \
  -v "%cd%:/project" \
  -v "%HomeDrive%%HomePath%/.dockagator:/root/.local/share" \
  gatoreducator/dockagator

Please note that not all version of the Windows terminal window will correctly recognize the use of the %cd% and %HomeDrive%%HomePath% variables. In this case, you should substitute the actual directory for a specific course assignment for the %cd% variable and the drive letter that contains the .dockagator directory for the %HomeDrive%%HomePath% variable. Finally, the Windows terminal window may not work correctly when you attempt to run a multi-line command. In this case, you should break up the aforementioned four-line command into separate lines, like docker run --rm --name dockagator and -v "%cd%:/project" and then connect them into a single long line that you separate by a single space. Here is an example of what the long command would look like, again assuming that the Windows cmd terminal correctly interprets the %cd% and %HomeDrive%%HomePath% variables:

docker run -it --rm --name dockagator -v "%cd%:/project" -v "%HomeDrive%%HomePath%/.dockagator:/root/.local/share" gatoreducator/dockagator /bin/bash

Here are some additional commands that you may need to run when using Docker:

  • docker info: display information about how Docker runs on your workstation
  • docker images: show the Docker images installed on your workstation
  • docker container list: list the active images running on your workstation
  • docker system prune: remove many types of "dangling" components from your workstation
  • docker image prune: remove all "dangling" docker images from your workstation
  • docker container prune: remove all stopped docker containers from your workstation
  • docker rmi $(docker images -q) --force: remove all docker images from your workstation

Commands for an Interactive Docker Shell

Since the above docker run command uses a Docker images that, by default, runs gradle grade and then exits the Docker container, you may want to instead run the following command so that you enter an "interactive terminal" that will allow you to repeatedly run commands within the Docker container. Don't forget that, if you are using the Windows operating system, then you will need to use a different command to run Docker, as explained previously in this document. Importantly, the command that you type if you are a Windows user should still contain the -it at the start of the docker run and the /bin/bash at the end of the command. However, the other components of this command need to be customized for the Windows operating system.

If you use either MacOS or Linux, then this is the command that you would run to enter into the interactive terminal provided by a Docker container:

docker run -it --rm --name dockagator \
  -v "$(pwd)":/project \
  -v "$HOME/.dockagator":/root/.local/share \
  gatoreducator/dockagator /bin/bash

If you use Windows, then this is the command that you would run to enter into the interactive terminal provided by a Docker container:

docker run -t --rm --name dockagator \
  -v "%cd%:/project" \
  -v "%HomeDrive%%HomePath%/.dockagator:/root/.local/share" \
  gatoreducator/dockagator /bin/bash

Once you have typed this command, you can use the GatorGrader tool in the Docker container by typing the command gradle grade in your terminal. Running this command will produce a lot of output that you should carefully inspect. If GatorGrader's output shows that there are no mistakes in a course assignment, then your source code and technical writing are passing all of the automated baseline checks. However, if the output indicates that there are mistakes, then you will need to understand what they are and then try to fix them.

Remember, to correctly run any of the commands mentioned in this guide, you must be in the main (i.e., "home base") directory for a course assignment where the build.gradle file is located.

Upgrading the Docker Container

If the course instructor provides a new version of the Docker container called gatoreducator/dockagator and you want to receive it immediately, you must first delete the existing Docker container on your laptop by running the command docker rmi gatoreducator/dockagator. Next, you can re-run one of the aforementioned Docker commands, like the following one, which would work on MacOS or Linux:

docker run -it --rm --name dockagator \
  -v "$(pwd)":/project \
  -v "$HOME/.dockagator":/root/.local/share \
  gatoreducator/dockagator /bin/bash

Please note that if you attempt to run gradle grade in an updated Docker container it is possible that the command will execute incorrectly if you previously used GatorGrader with a Docker container that featured a different version of the Python programming language. In this situation, you should delete the directories inside of the .dockagator directory and then again attempt to run the gradle grade command inside of the Docker container. Specifically, you will need to delete directories in .dockagator that are normally called gatorgrader, virtualenv, and virtualenvs.