docker icon indicating copy to clipboard operation
docker copied to clipboard

Fix cron container by using `volumes_from`

Open relikd opened this issue 3 years ago • 6 comments

I suggest replacing:

https://github.com/nextcloud/docker/blob/de77074a55a7d181276de5cddf9fbdb5b9e56f3e/.examples/docker-compose/insecure/mariadb/apache/docker-compose.yml#L37-L41

with:

volumes_from:
  - app

instead of using a direct volume mapping. (and for all example configs)

I had to debug this issue for the last two days and this all could be avoided with the proper config. In particular, cron has no write access to the filesystem if you do not import all the same volumes. E.g., I had this config and thought it would be enough to only import the main volume without the individual volumes within the parent volume.

cron:
  volumes:
    - nextcloud:/var/www/html
app:
  volumes:
    - nextcloud:/var/www/html
    - ./data:/var/www/html/data
    - ./config:/var/www/html/config
    - ./custom_apps:/var/www/html/custom_apps

But it turns out, whenever you open a volume within another volume, the cron container will not see the content of the data, config, and custom_apps directories.

relikd avatar Oct 31 '22 15:10 relikd

This just saved me a lot more time debugging. I already wasted a fair bit since the container logs show it running just fine, but the WebUI doesn't :joy: thank you!

skarekrow avatar May 21 '23 20:05 skarekrow

HI @relikd - Thanks for your report. Yes, all volumes need to match on the app and cron containers - just like in the example provided. This is more a general Docker configuration matter:

https://docs.docker.com/compose/compose-file/compose-file-v3/#volume-configuration-reference

As for using volumes_from - it is deprecated and not even supported in more recent Compose files:

https://docs.docker.com/compose/compose-file/compose-versioning/#version-3 https://docs.docker.com/compose/compose-file/compose-versioning/#upgrading

volumes is the correct alternative.

I don't think there's anything more to be done for this issue, so please close it out. You're also welcome to submit PRs against the examples if you think they could be more clearly presented. Perhaps have multiple volumes shown would make it clearer?

joshtrichards avatar Jul 19 '23 16:07 joshtrichards

And how exactly should the config file look like without volumes_from? I stated in the example above that it will break functionality as soon as you add other volume mappings to the app (but not cron). This is not reflected in the example config. Users might want to add custom volumes to the app – not realizing they will break cron that way.

relikd avatar Jul 20 '23 08:07 relikd

All volumes in app and cron should in sync

cron:
  volumes:
    - nextcloud:/var/www/html
    - ./data:/var/www/html/data
    - ./config:/var/www/html/config
    - ./custom_apps:/var/www/html/custom_apps
app:
  volumes:
    - nextcloud:/var/www/html
    - ./data:/var/www/html/data
    - ./config:/var/www/html/config
    - ./custom_apps:/var/www/html/custom_apps

martadinata666 avatar Jul 20 '23 09:07 martadinata666

Can this be added as a comment to the example config? something like "make sure to also update cron and keep both in sync or otherwise none will work"?

relikd avatar Jul 20 '23 09:07 relikd

Can this be added as a comment to the example config?

Sure. Feel free to fork+edit (here in GH) the examples you think it should be in. Then submit the PR(s) (and mention this issue).

joshtrichards avatar Mar 25 '24 20:03 joshtrichards