Software Exercise 1.1: Run and Explore Containers¶
Objective: Observe the differences between the base environment and the environment inside a container.
Why learn this?: Being able to run a container directly allows you to confirm what is installed and whether any additional scripts or code will work in the context of the container.
Setup¶
Make sure you are logged into ap40.uw.osg-htc.org or ap41.uw.osg-htc.org. For this exercise
we will be using Apptainer containers maintained by OSG staff or existing
containers on Docker Hub.
There is some set-up that we should do to help lighten the load on the Access Point as we work with containers.
First, download the apptainer-setup.sh script:
pelican object get osdf:///osg-public/school/2026/apptainer-setup.sh ./
Then run the script using this command:
. apptainer-setup.sh
You should see a message that the setup has been completed. (This is the only time you'll need to run this script.)
What is our default environment?¶
-
Type the following commands on your Access Point.
$ grep "PRETTY_NAME" /etc/os-release $ python3 --version $ R --version $ gcc --version -
Each of these commands tells you something about the software and operating system that is available on the Access Point itself.
- What is the version of Linux on the Access Point?
- Which commands (
python,R,gcc) don't run at all? Why might that be? - What are the versions of the programs that did run?
Full Linux version information
In the above example, we used
grepto only show the value of thePRETTY_NAMEin the/etc/os-releasefile. There's a lot more information in that file about the Linux version, which you can see with$ cat /etc/os-release
Exploring a different environment with Apptainer¶
Now, let's explore a container from the OSG-Supported List.
-
Find the full path for the
ubuntu 24.04container image. -
To run it, use this command:
$ apptainer shell /cvmfs/singularity.opensciencegrid.org/htc/ubuntu:24.04It may take a few minutes to start - don't worry if this happens.
About the
/cvmfspathIn the above example, we used a path beginning with
/cvmfsto launch a container.This should be the only place that you use such a path!
-
Once the container starts, the prompt will change to either
Singularity>orApptainer>. Runlsandpwd. Where are you? Do you see your files? -
The
apptainer shellcommand will automatically connect your home directory to the running container so you can use your files. -
Run the same test commands as before:
$ grep "PRETTY_NAME" /etc/os-release $ python3 --version $ R --version $ gcc --version -
Compare and contrast with what happened when you ran the commands in the default Access Point environment. What changed?
-
Exit out of the container by typing
exit.
Apply to Your Work¶
Consider what it takes to install your software - has it been tested on specific versions of Linux? Does it need special libraries? Depend on a certain version of Python? Containers are a way to make sure all the correct elements are in place for your software to work successfully and consistently.