Skip to content

Jobs

Warning

This feature is currently in beta. It works as expected but there might still be bugs or limitations. As a result, it is also subject to changes.

Services can also be defined as a job: one-off task than runs successfully to completion and then stops. Running succesfully to completion means that the job exits its process without errors (non-zero exit status).

To launch a job, we need to specify the io.levv.kind label for the service as such.

services:
  calculate-pi:
    image: perl
    entrypoint:
      - perl
      - "-Mbignum=bpi"
      - "-wle"
      - "print bpi(2000)"
    labels:
      "io.levv.kind": "job"

No restart jobs

When a job exits with errors (non-zero exit status), levv will attempt to relaunch it up to five times, expecting a sucessful completion. If we want to perform a strict one-off task, independently of its exit status, we need to specify a restart policy for that.

services:
  tofail:
    image: docker.io/library/bash:5
    command: ["bash"]
    entrypoint:
      - -c
      - echo "Hello world!" && sleep 5 && exit 42
    labels:
      "io.levv.kind": "job"
    restart: no

Currently the only supported value is no.