apptainer / apptainer-userdocs

Other
4 stars 25 forks source link

Set PATH to sif files #279

Closed nick-youngblut closed 3 months ago

nick-youngblut commented 3 months ago

Which Document page:

Quck Start

Expected results:

I'm used to Docker, where there are no sif files to specify. One can just run docker run <name_of_image>. AFAIK, apptainer run requires the user to specify the path to the sif file.

All of the apptainer docs seem to assume that the sif file is in the user's working directory (e.g., apptainer run lolcow_latest.sif). There doesn't seem to be any clear docs on whether/how one can set a PATH-like variable that defines where apptainer run will look for sif files, if the sif file is not in the user's working directory. For example:

# set the location of 
APPTAINER_SIF_DIR=${HOME}/apptainer_sif_files/

# execute `apptainer run` from any location
apptainer run lolcow_latest.sif 

# lolcow_latest.sif is not in the working directory, so `apptainer run` looks in $APPTAINER_SIF_DIR

If this is not possible, it would help to explicitly state that one must always provide the path to the sif file... or create some sort of custom alias/function to set the directory where all sif files are located (if the specified sif file path does not exist).

Actual results:

It would be helpful if the user could organize all sif files in >=1 specific locations (repositories) and easily call any one of these sif files without the need to provide the full to the sif file or create a custom setup (e.g., an alias or function).

DrDaveD commented 3 months ago

This is a fundamental difference between docker and apptainer, a different approach which many people like. I don't think that will be changing. If you need the capability of searching multiple directories, you can add it in a wrapper script.

You can also just type the name of a container file and the shell should search through the PATH and run it with apptainer. See https://apptainer.org/docs/user/latest/quick_start.html#running-a-container.

nick-youngblut commented 3 months ago

@DrDaveD where do the docs state that apptainer will search the user's PATH for sif files? I tried this approach, but it didn't work. All of the sif files are in ${HOME}/apptainers/, and I added ${HOME}/apptainers/ to my PATH, but apptainer couldn't find the sif files.

DrDaveD commented 3 months ago

It doesn't explicitly say it will search the PATH but it says you can run it as any other executable. Just type the full name of your container as a command (without the ./ like it shows in the example).