Open avataru opened 3 years ago
Hi @avataru,
Since you are using job labels (https://github.com/mcuadros/ofelia/blob/master/docs/jobs.md) you should apply those labels to the target container (when using job-exec
) so in the case of your first project, the Ofelia labels should be on the app
service definition instead of the scheduler service definition.
Additionally, when applying labels to the target container you do not need to provide the target container name (https://github.com/mcuadros/ofelia/blob/master/docs/jobs.md#job-exec).
Already tried that and didn't make any difference. The second ofelia container log will show the jobs from both containers (myjob and myotherjob) even if they are set on their respective containers.
Any update to this? I've also tried what you suggested @hemenkapadia and the jobs are still logging across containers.
Same issue here
Below is my workaround. On startup it just writes to a config file and runs ofelia with that instead of using labels. I wanted to keep the schedule in the same docker-compose file rather than maintaining a separate .ini file.
ofelia:
image: mcuadros/ofelia:v0.3.4
entrypoint: []
command: /bin/sh -c 'echo "$$OFELIA_CONFIG" >> /tmp/ofelia.ini && ofelia daemon --config=/tmp/ofelia.ini'
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
environment:
OFELIA_CONFIG: |-
[job-run "some_job"]
schedule = 0 42 * * * *
delete = false
container = some_container
Thanks @ddebie, I will try your workaround
Any update on this., I have exactly the same issue. It does look like not only logging but the second one runs both jobs!! instead of respecting the container that specifies the label with 'ofelia.job-exec'
Thanks @ddebie. Solved my problem with a slightly modification with job-exec so that the job runs in the container bringing up with the docker-compose.
OFELIA_CONFIG: |-
[job-exec "remove_old_video"]
schedule = @every 24h
container = record-video
command = find /root/video/ -type f -mtime +60 -exec rm -f {} +
This is a feature of Ofelia, you only need one Ofelia Instance running per Host, it will take care of every container/project having Ofelia labels. There is no need to run multiple Ofelia instances per host. It is the same as with SSL Proxies (Traefik, jwilder, nginx, ...) - you will run only one per host, not one per project.
I have two almost identical projects. When I start the second project Ofelia seems to also run the jobs on the first project.
first project's docker-compose.yml
second project's docker-compose.yml
Docker's log for the first container will look like this:
While the second:
What do I need to set so this doesn't happen and each Ofelia container is only concerned about their project?
Thank you