Re: [HTCondor-devel] Inclusion of additional arguments to docker run


Date: Mon, 12 Oct 2015 13:13:41 +0100
From: Brian Candler <b.candler@xxxxxxxxx>
Subject: Re: [HTCondor-devel] Inclusion of additional arguments to docker run
Here's a more generic wrapper script which allows arbitrary docker options, as well as attaching volumes.

=== /etc/condor/condor_config.local ===
DOCKER = /usr/local/bin/docker-wrapper

=== /usr/local/bin/docker-wrapper ===
#!/usr/bin/python
import os
import sys
if sys.argv[1] != "run":
    os.execv("/usr/bin/docker", sys.argv)
try:
    i = sys.argv.index("---")
except ValueError:
    os.execv("/usr/bin/docker", sys.argv)
# docker run opt... image command foo... --- bar...
# becomes:
# docker run bar... opt... image command foo...
os.execv("/usr/bin/docker", sys.argv[0:2] + sys.argv[i+1:] + sys.argv[2:i])

Now anything in "arguments" which comes after a triple-dash is taken to be additional options to the docker run command.

Example submit file:

universe = docker
executable = ls
arguments = "-l /data --- -v /data:/data"
docker_image = ubuntu
output = test.out
queue

I think this is a reasonable workaround, especially if in the end condor would support this natively using e.g.

arguments = "-l /data"
docker_options = "-v /data:/data"

However this does still rely on the user setting suitable requirements expression to match the appropriate hosts. If you wanted to make this more automatic then you could have a more limited syntax such as

docker_volumes = "/shared:/shared /media:/media"
docker_volumes_from = "othercontainer"

which, as well as adding the -v / --volumes-from options, could add requirements such as

stringListMember(split(docker_data_directories,":"), "/shared")
stringListMember(split(docker_data_directories,":"), "/media")
stringListMember(split(docker_data_volumes",":"), "othercontainer")

Does either approach seem reasonable?

Regards,

Brian.

[← Prev in Thread] Current Thread [Next in Thread→]