Environment Variables
Environment variables are one of the main ways to configure software running inside a container, and as we have mentioned before, Apptainer copies the environment variables that are available to the inside of the container. If your software behaves differently than expected, one of the starting diagnostic points is to inspect the environment variables inside the container.
Environment Variables
When you launch a container, the environment variables from your shell are copied to the shell in the container by default. Any variable you export before the launch is also exported inside the container:
Setting and Cleaning Variables
Besides adding environment variables before starting a container, Apptainer provides more convenient methods to add environment variables into the container. You can specify variables on the command line with --env, or you can read them from a file with --env-file.
If you want to start a container without your environment variables copied in, consider using the --cleanenv flag. The container still gets a minimal baseline plus any variables set in the image, along with whatever you add with --env or --env-file.
CVW material development is supported by NSF OAC awards 1854828, 2321040, 2323116 (UT Austin) and 2005506 (Indiana University)