ofelia icon indicating copy to clipboard operation
ofelia copied to clipboard

ofelia in docker-mode did not allow job-run on non-ofelia containers, is this correct?

Open jk opened this issue 3 years ago • 2 comments

I've modified the example from the readme to run a seperate container from the nginx service, like so:

version: "3.8"

services:
  ofelia:
    image: mcuadros/ofelia:latest
    depends_on:
      - nginx
    command: daemon --docker
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro

  nginx:
    image: nginx:latest
    labels:
      ofelia.enabled: "true"
      ofelia.job-run.ofelia-test.schedule: "@every 5s"
      ofelia.job-run.ofelia-test.image: "alpine:latest"
      ofelia.job-run.ofelia-test.command: "date"

But ofelia doesn't seem to find the job-run labels:

ofelia-test-ofelia-1  | unable to start a empty scheduler.
ofelia-test-ofelia-1 exited with code 1

IMO I expect ofelia to pick up the labels annotated in the nginx service, but no. When moving these exact same labels to the ofeila service, it works:

version: "3.8"

services:
  ofelia:
    image: mcuadros/ofelia:latest
    depends_on:
      - nginx
    command: daemon --docker
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    labels:
      ofelia.enabled: "true"
      ofelia.job-run.ofelia-test.schedule: "@every 5s"
      ofelia.job-run.ofelia-test.image: "alpine:latest"
      ofelia.job-run.ofelia-test.command: "date"

  nginx:
    image: nginx:latest

and I get the following error on starting up ofelia:

ofelia-test-ofelia-1  | 2021-11-29T15:51:30.797Z  scheduler.go:34 ▶ NOTICE New job registered "ofelia-test" - "date" - "@every 5s"
ofelia-test-ofelia-1  | 2021-11-29T15:51:30.798Z  scheduler.go:54 ▶ DEBUG Starting scheduler with 1 jobs
ofelia-test-ofelia-1  | 2021-11-29T15:51:35.003Z  common.go:125 ▶ NOTICE [Job "ofelia-test" (4f1c4b5a7b36)] Started - date
ofelia-test-ofelia-1  | 2021-11-29T15:51:36.964Z  common.go:125 ▶ NOTICE [Job "ofelia-test" (4f1c4b5a7b36)] Pulled image alpine:latest
ofelia-test-ofelia-1  | 2021-11-29T15:51:37.331Z  common.go:125 ▶ NOTICE [Job "ofelia-test" (4f1c4b5a7b36)] StdOut: Mon Nov 29 15:51:37 UTC 2021
ofelia-test-ofelia-1  | 2021-11-29T15:51:37.331Z  common.go:125 ▶ NOTICE [Job "ofelia-test" (4f1c4b5a7b36)] Finished in "2.328118001s", failed: false, skipped: false, error: none

Looks like ofelia isn't able start seperate containers for non-ofeila images. According to https://github.com/mcuadros/ofelia/blob/master/docs/jobs.md#job-run this is nowhere stated, is this a bug or the intended behavior?

jk avatar Nov 29 '21 15:11 jk

Remove the --docker parameter.

edgardleal avatar Oct 05 '23 19:10 edgardleal

My problem looks similar see #270 (I'm not using this --docker parameter) Documentation about how to use job-run with labels should probably be improved. I will do (if I understand what is wrong with my settings)

s-celles avatar Apr 11 '24 20:04 s-celles