+ $command .= "&& exec arv-mount --allow-other $ENV{TASK_KEEPMOUNT} --exec ";
+ if ($docker_hash)
+ {
+ $command .= "crunchstat -cgroup-root=/sys/fs/cgroup -cgroup-parent=docker -cgroup-cid=$ENV{TASK_WORK}/docker.cid -poll=10000 ";
+ $command .= "$docker_bin run --rm=true --attach=stdout --attach=stderr --user=crunch --cidfile=$ENV{TASK_WORK}/docker.cid ";
+ # Dynamically configure the container to use the host system as its
+ # DNS server. Get the host's global addresses from the ip command,
+ # and turn them into docker --dns options using gawk.
+ $command .=
+ q{$(ip -o address show scope global |
+ gawk 'match($4, /^([0-9\.:]+)\//, x){print "--dns", x[1]}') };
+ $command .= "--volume=\Q$ENV{CRUNCH_SRC}:/tmp/crunch-src:ro\E ";
+ $command .= "--volume=\Q$ENV{TASK_KEEPMOUNT}:/keep:ro\E ";
+ $command .= "--env=\QHOME=/home/crunch\E ";
+ while (my ($env_key, $env_val) = each %ENV)
+ {
+ if ($env_key =~ /^(ARVADOS|JOB|TASK)_/) {
+ if ($env_key eq "TASK_WORK") {
+ $command .= "--env=\QTASK_WORK=/tmp/crunch-job\E ";
+ }
+ elsif ($env_key eq "TASK_KEEPMOUNT") {
+ $command .= "--env=\QTASK_KEEPMOUNT=/keep\E ";
+ }
+ elsif ($env_key eq "CRUNCH_SRC") {
+ $command .= "--env=\QCRUNCH_SRC=/tmp/crunch-src\E ";
+ }
+ else {
+ $command .= "--env=\Q$env_key=$env_val\E ";
+ }
+ }
+ }
+ $command .= "--env=\QCRUNCH_NODE_SLOTS=$ENV{CRUNCH_NODE_SLOTS}\E ";
+ $command .= "\Q$docker_hash\E ";
+ $command .= "stdbuf --output=0 --error=0 ";
+ $command .= "/tmp/crunch-src/crunch_scripts/" . $Job->{"script"};
+ } else {
+ # Non-docker run
+ $command .= "crunchstat -cgroup-root=/sys/fs/cgroup -poll=10000 ";
+ $command .= "stdbuf --output=0 --error=0 ";
+ $command .= "$ENV{CRUNCH_SRC}/crunch_scripts/" . $Job->{"script"};
+ }
+