diff --git a/SingularityExecutor/src/main/java/com/hubspot/singularity/executor/shells/SingularityExecutorShellCommandDescriptor.java b/SingularityExecutor/src/main/java/com/hubspot/singularity/executor/shells/SingularityExecutorShellCommandDescriptor.java index 3393c30699..a296ea22d0 100644 --- a/SingularityExecutor/src/main/java/com/hubspot/singularity/executor/shells/SingularityExecutorShellCommandDescriptor.java +++ b/SingularityExecutor/src/main/java/com/hubspot/singularity/executor/shells/SingularityExecutorShellCommandDescriptor.java @@ -27,6 +27,9 @@ public class SingularityExecutorShellCommandDescriptor { @JsonProperty private boolean skipCommandPrefix = false; + @JsonProperty + private boolean skipCommandPrefixDockerOnly = false; + public List getOptions() { return options; } @@ -58,4 +61,12 @@ public boolean isSkipCommandPrefix() { public void setSkipCommandPrefix(boolean skipCommandPrefix) { this.skipCommandPrefix = skipCommandPrefix; } + + public boolean isSkipCommandPrefixDockerOnly() { + return skipCommandPrefixDockerOnly; + } + + public void setSkipCommandPrefixDockerOnly(boolean skipCommandPrefixDockerOnly) { + this.skipCommandPrefixDockerOnly = skipCommandPrefixDockerOnly; + } } diff --git a/SingularityExecutor/src/main/java/com/hubspot/singularity/executor/shells/SingularityExecutorShellCommandRunner.java b/SingularityExecutor/src/main/java/com/hubspot/singularity/executor/shells/SingularityExecutorShellCommandRunner.java index 03f30c466d..931d6af480 100644 --- a/SingularityExecutor/src/main/java/com/hubspot/singularity/executor/shells/SingularityExecutorShellCommandRunner.java +++ b/SingularityExecutor/src/main/java/com/hubspot/singularity/executor/shells/SingularityExecutorShellCommandRunner.java @@ -143,13 +143,15 @@ public boolean apply(SingularityExecutorShellCommandDescriptor input) { List command = new ArrayList<>(); - if (!shellCommandDescriptor.isSkipCommandPrefix()) { - command.addAll(executorConfiguration.getShellCommandPrefix()); - } - boolean isDocker = task.getTaskInfo().hasContainer() && task.getTaskInfo().getContainer().hasDocker(); if (isDocker) { + if (!shellCommandDescriptor.isSkipCommandPrefix() && !shellCommandDescriptor.isSkipCommandPrefixDockerOnly()) { + command.addAll(executorConfiguration.getShellCommandPrefix()); + } + command.addAll(Arrays.asList("docker", "exec", String.format("%s%s", executorConfiguration.getDockerPrefix(), task.getTaskId()))); + } else if (!shellCommandDescriptor.isSkipCommandPrefix()) { + command.addAll(executorConfiguration.getShellCommandPrefix()); } command.addAll(shellCommandDescriptor.getCommand());