No, apptainer run does not automatically source ~/.bashrc like an interactive login shell would.
apptainer run: Executes the %runscript in a non-interactive shell → .bashrc is not sourced.apptainer shell: Starts an interactive shell → .bashrc is sourced (if using Bash and the file exists in the container or mounted home).Explicitly source it in %runscript (for apptainer run):
bash# In your Singularity/Apptainer definition file: %runscript source ~/.bashrc && exec "$@"
Use BASH_ENV (for non-interactive Bash):
bash%environment export BASH_ENV=/path/to/your/bashrc
Switch to apptainer shell if you need an interactive environment with .bashrc loaded.
Mount and source manually:
bashapptainer run --bind ~/.bashrc:/root/.bashrc your_container.sif
(Then ensure the runscript sources it.)
For most cases, option 1 or 2 is the cleanest equivalent.
Vibe can make mistakes. Check answers. Learn more