Software Exercise 4.3: Using Docker¶
In this exercise, you will run the same Python script as the other Python exercises, but using a Docker container.
Setup¶
For this exercise, you will need to be logged into learn.chtc.wisc.edu
, not login04.osgconnect.net
. If you haven't done one of the previous Python exercises,
make sure to get a copy of the script and recommended commands here.
Submit File Changes¶
- Make a copy of your submit file from the previous Python exercise or build from an existing submit file.
-
Add the following lines to the submit file or modify existing lines to match the lines below:
universe = docker docker_image = python:3.7.0-stretch
Here we are requesting HTCondor's Docker universe and using a pre-built python image that, by default, will be pulled from a public website of Docker images called DockerHub. The requirements line will ensure that we run on computers whose operating system can support Docker.
-
Adjust the executable and arguments lines. The executable can now be the Python script itself, with the appropriate arguments:
executable = fib.py arguments = 90
-
Finally, we no longer need to transfer a Python tarball (whether source code or pre-built) or our Python script. You can remove both from the
transfer_input_files
line of the submit file if it's already present.
Python Script¶
-
Open the Python script and add the following line at the top:
#!/usr/bin/env python3
This will ensure that the script uses the version of Python that comes in the Docker container.
Once these steps are done, submit the job.