-1

I have tried everything and I just can’t get an exec type job to run. I tried it on 3 different clusters and it fails on all.

The job prunes docker containers and just runs docker system prune -a.

This is the config section:

driver = "exec"
config {
  command = "bash"
  args = ["-c",
  " docker system prune -a "]
}

No logs and containers are not pruned:

job "docker-cleanup" {
  type = "system"
  constraint {
    attribute = "${attr.kernel.name}"
    operator  = "="
    value     = "linux"
  }
  datacenters = ["dc1"]
  group "docker-cleanup" {

    restart {
      interval = "24h"
      attempts = 0
      mode     = "fail"
    }
    task "docker-system-prune" {
      driver = "exec"
      config {
        command = "bash"
        args = ["-c",
        " docker system prune -a "]
      }
      resources {
        cpu    = 100
        memory = 50
        network {
          mbits = 1
        }
      }
    }
  }
}

What am I doing wrong?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • Can you include the log output from the failed job runs? Are there any allocation logs? Why does nomad say it's failing? – maxm May 28 '20 at 17:22

2 Answers2

0

I would suggest you provide the output to make it easier to analyze.

One thing you can try, is to add the full path to the bash executable.

   driver = "exec"
    config {
      command = "/bin/bash"
      args = ["-c",
      " docker system prune -a "]
    }

Further you are missing the "--force" parameter on system prune, without it - docker system prune asks for confirmation.

docker system prune --all --force
opHASnoNAME
  • 20,224
  • 26
  • 98
  • 143
0

As I know all args should be provided separately:

driver = "exec"
config {
  command = "/bin/bash"
  args = [
    "-c", "docker", "system", "prune", -a "
  ]
}
Vadim Che
  • 3
  • 3