# General question on cached Nextflow containers

**URL:** <https://community.seqera.io/t/general-question-on-cached-nextflow-containers/1759>\
**Category:** Ask for help\
**Tags:** nextflow\
**Created:** [February 20, 2025, 4:48pm UTC](https://community.seqera.io/t/general-question-on-cached-nextflow-containers/1759 "2025-02-20T16:48:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ramirobarrantes](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/ramirobarrantes/32/717_2.png) [@ramirobarrantes](https://community.seqera.io/u/ramirobarrantes)\
**Post date:** [February 20, 2025, 4:48pm UTC](https://community.seqera.io/t/general-question-on-cached-nextflow-containers/1759/1 "2025-02-20T16:48:42Z")

</div>

I have a very general question. Many people use an HPC at our organization and dozens use nf-core/nextflow pipelines. We were considering creating a general cache directory, NXF\_APPTAINER\_CACHEDIR accessible to everyone, and we would tell people to use that. The idea being that then all the container images would go into one place, instead of each user having their own. Does this sound like a good idea or more like opening a can of worms?

---

<div class="post-metadata">

**Author:** ![robsyme](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/robsyme/32/342_2.png) [@robsyme](https://community.seqera.io/u/robsyme)\
**Post date:** [February 20, 2025, 8:17pm UTC](https://community.seqera.io/t/general-question-on-cached-nextflow-containers/1759/2 "2025-02-20T20:17:59Z")

</div>

Great question Ramiro

My recommendations would be to use both the cachedir and librarydir variables.

- Use `NXF_APPTAINER_CACHEDIR` (per-user location with read+write) for a user’s containers.
- Use `NXF_APPTAINER_LIBRARYDIR` (system-wide with users having read-only access) for cluster-wide containers.

Nextflow checks `NXF_APPTAINER_LIBRARYDIR` first, and if the sif file isn’t there, Nextflow checks `NXF_APPTAINER_CACHEDIR`. If the container doesn’t exist in either location, Nextflow grabs the container from [wherever.com/my-container.sif](http://wherever.com/my-container.sif) and then writes it to NXF\_APPTAINER\_CACHEDIR. I think it makes more sense for sysadmins to manually copy across common containers to the LIBRARYDIR if they see lots of people using them.

You can pull the containers of all of your really common nf-core workflows (using `nextflow inspect`) and write them into `NXF_APPTAINER_LIBRARYDIR` as an elevated user to ensure that other users don’t download them.

---

<div class="post-metadata">

**Author:** ![ramirobarrantes](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/ramirobarrantes/32/717_2.png) [@ramirobarrantes](https://community.seqera.io/u/ramirobarrantes)\
**Post date:** [February 21, 2025, 5:49pm UTC](https://community.seqera.io/t/general-question-on-cached-nextflow-containers/1759/3 "2025-02-21T17:49:49Z")

</div>

Thank you @robsyme, this is great advice

---

<div class="post-metadata">

**Author:** ![ramirobarrantes](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/ramirobarrantes/32/717_2.png) [@ramirobarrantes](https://community.seqera.io/u/ramirobarrantes)\
**Post date:** [February 28, 2025, 5:50pm UTC](https://community.seqera.io/t/general-question-on-cached-nextflow-containers/1759/4 "2025-02-28T17:50:47Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
