Skip to content

Containers

This page contains instructions and examples for running containers on the GMC Research Cyclecloud HPC cluster.


Container Support

Containers are supported on the GMC Research Cyclecloud HPC cluster using the Podman or Apptainer container engines. Podman is a drop-in replacement for Docker; if you are already familiar with Docker, you can use all the same commands! Apptainer is the open source version of Singularity (formerly Singularity Community Edition [SingularityCE]). The Apptainer commands are not aliased to docker and must be called using the apptainer CLI.

There are several key differences between running containers in an HPC environment and running them on your own computer:

  1. All containers are rootless. They run under your account, and do not have elevated privileges.
    • You cannot use privileged network ports (<1025).
  2. Containers are ephemeral. When your job ends, any containers that have not been pushed to a registry will be deleted.
    • Container data is stored locally on each compute node.
  3. The login node (cmri-vm-login) does not support containers. You must use compute nodes for all container operations.
    • Interactive sessions are the recommended way to build containers.

When running a container for the first time on a node, you may see an error like this:

ERRO[0000] cannot find UID/GID for user: No subuid ranges found for user in /etc/subuid - check rootless mode in man pages.

These errors can be safely ignored.

Example Workflows

Given the constraints mentioned above, this section has several example workflows demonstrating how you can run containers on the cluster.

Building and Running

The steps below walk through building and running a container on the Research Cyclecloud cluster using Podman.

  1. Log in to research.cyclecloud.cmh.internal and start an interactive session:

    srun --pty /bin/bash
    
  2. In the interactive session, build your container from a Dockerfile:

    docker build -t example .
    
  3. Once the build finishes, run the container:

    docker run example
    

Remember - local container images are deleted when your job ends. You must push your container images to a repository to preserve them.

Example output for these steps is shown below:

(NODE:D2-1) [jgregor@ip-0A646A0E ~]$ cat ./Dockerfile
FROM registry.access.redhat.com/ubi8/ubi

RUN dnf install -yq --disableplugin=subscription-manager https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm 1>/dev/null
RUN dnf install -yq --disableplugin=subscription-manager --enablerepo epel cowsay 1>/dev/null

CMD cowsay "hello world!"
(NODE:D2-1) [jgregor@ip-0A646A0E ~]$ docker build -t example .
STEP 1: FROM registry.access.redhat.com/ubi8/ubi
STEP 2: RUN dnf install -yq --disableplugin=subscription-manager https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm 1>/dev/null
--> 08671cc61f9
STEP 3: RUN dnf install -yq --disableplugin=subscription-manager --enablerepo epel cowsay 1>/dev/null
Importing GPG key 0x2F86D6A1:
 Userid     : "Fedora EPEL (8) "
 Fingerprint: 94E2 79EB 8D8F 25B2 1810 ADF1 21EA 45AB 2F86 D6A1
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
--> d5a21d84874
STEP 4: CMD cowsay "hello world!"
STEP 5: COMMIT example
--> 01c65dbce97
01c65dbce97c225942735cd7a8ffeddabf50577b786738885d749cd83b8f5896
(NODE:D2-1) [jgregor@ip-0A646A0E ~]$ docker run example
 ______________
< hello world! >
 --------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Using GPUs

The steps below walk through running a GPU enabled container.

  1. Start an interactive session on a GPU node:

    srun -p gpu --gpus=1 --pty /bin/bash
    
  2. Pull a GPU enabled container:

    docker pull nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda11.7.1-ubuntu20.04
    
  3. Run the container:

    docker run cuda-sample:vectoradd-cuda11.7.1-ubuntu20.04
    

Example output for these steps is shown below:

[cdietz1@cmri-gpu02 ~]$ docker pull nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda11.7.1-ubuntu20.04
Trying to pull nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda11.7.1-ubuntu20.04...
Getting image source signatures
Copying blob cde16ef91ac2 done
Copying blob 6c10428f3e1b done
Copying blob 3b65ec22a9e9 done
Copying blob 978ea3dcd5fb done
Copying blob 4f4fb700ef54 done
Copying blob 9bfa49b064c8 done
Copying blob 7c4464641354 done
Copying blob c7917bbfcfe8 done
Copying blob ac5184cb5a69 done
Copying blob acbe074771d6 done
Copying blob 78dc954ca047 done
Copying config c2dcfa922b done
Writing manifest to image destination
Storing signatures
c2dcfa922ba509153ba5d0d7f859853362da9532d82fbd9f2e54c444b47b0a77
[cdietz1@cmri-gpu02 ~]$ docker run cuda-sample:vectoradd-cuda11.7.1-ubuntu20.04
[Vector addition of 50000 elements]
Copy input data from the host memory to the CUDA device
CUDA kernel launch with 196 blocks of 256 threads
Copy output data from the CUDA device to the host memory
Test PASSED
Done
[cdietz1@cmri-gpu02 ~]$

Apptainer

Apptainer is accessessed through the apptainer CLI and has many of the familiar docker subcommands (pull, build, run, etc.). Apptainer/Singularity images are slightly different from Docker/Podman images however, so native docker containers may take an extra step to get running with Apptainer. Full documentation can be found in the Apptainer User Guide. Let's run the same cowsay example from earlier.

  1. Log in to research.cyclecloud.cmh.internal and start an interactive session:

    srun --pty /bin/bash
    
  2. In the interactive session, let us create an Apptainer definition file (def) and then build the container into a Singularity Image Format (sif).

    cat >lolcow.def <<EOF
    BootStrap: docker
    From: registry.access.redhat.com/ubi8/ubi
    
    %post
      dnf install -yq --disableplugin=subscription-manager https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm 1>/dev/null
      dnf install -yq --disableplugin=subscription-manager --enablerepo epel cowsay 1>/dev/null
    
    %environment
      export LC_ALL=C
    
    %runscript
      cowsay "hello world!"
    
    %labels
      Author John
    
    EOF
    
    apptainer build lolcow.sif lolcow.def
    
  3. Once the build finishes, run the image:

    apptainer run lolcow.sif
    

Below is the output from the above commands:

(NODE:D2-1) [jgregor@ip-0A646A0E ~]$ cat >lolcow.def <<EOF
> BootStrap: docker
> From: registry.access.redhat.com/ubi8/ubi
>
> %post
>   dnf install -yq --disableplugin=subscription-manager https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm 1>/dev/null
>   dnf install -yq --disableplugin=subscription-manager --enablerepo epel cowsay 1>/dev/null
>
> %environment
>   export LC_ALL=C
>
> %runscript
>   cowsay "hello world!"
>
> %labels
>   Author John
>
> EOF
(NODE:D2-1) [jgregor@ip-0A646A0E ~]$ apptainer build lolcow.sif lolcow.def
INFO:    Starting build...
INFO:    Fetching OCI image...
75.4MiB / 75.4MiB [=========================================================================================] 100 % 13.2 MiB/s 0s
INFO:    Extracting OCI image...
INFO:    Inserting Apptainer configuration...
INFO:    Running post scriptlet
+ dnf install -yq --disableplugin=subscription-manager https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
+ dnf install -yq --disableplugin=subscription-manager --enablerepo epel cowsay
Importing GPG key 0x2F86D6A1:
 Userid     : "Fedora EPEL (8) <epel@fedoraproject.org>"
 Fingerprint: 94E2 79EB 8D8F 25B2 1810 ADF1 21EA 45AB 2F86 D6A1
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
INFO:    Adding labels
INFO:    Adding runscript
INFO:    Creating SIF file...
[======================================================================================================================] 100 % 0s
INFO:    Build complete: lolcow.sif
(NODE:D2-1) [jgregor@ip-0A646A0E ~]$ apptainer run lolcow.sif
 ______________
< hello world! >
 --------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
(NODE:D2-1) [jgregor@ip-0A646A0E ~]$

You can find additional documentation in the Apptainer User Guide.