This guide provides step-by-step instructions for creating, deploying, and running containers using Docker and Singularity on the Dardel cluster.
If you've modified a running container, save its state as a new image:
docker commit <container_id_or_name> <repository>:<tag>Example:
docker commit flamboyant_agnesi drowsygoat/r_archr:1.0.4Upload the container image to Docker Hub for easy access from the cluster:
docker push <repository>:<tag>Example:
docker push drowsygoat/r_archr:1.0.4Before deploying, verify and refine the container by running it locally:
docker run -it -v $(pwd):/mnt <repository>:<tag>Example:
docker run -it -v $(pwd):/mnt drowsygoat/r_archr:1.0.3Load Singularity module if not loaded
ml singularityPull the Docker container into a Singularity Image Format (SIF) file:
singularity pull -F <output_filename>.sif docker://<repository>:<tag>Example:
singularity pull -F r_archr.sif docker://drowsygoat/r_archr:1.0.4Use the sing.sh script to execute commands inside the container:
sing.sh -B <bind_path> <sandbox_name> <command> [options...]Example:
sing.sh -B /cfs/klemming/ r_archr Rscript "$my_script" --dir "$JOB_NAME" --name "$sample_id" --sample "$sample_path" --threads "$cpus" --gtf "$anno"The sing.sh script simplifies running containers on the cluster with proper bindings and environment isolation.
-
Default Paths:
- Local Base Path:
/cfs/klemming/projects/snic/sllstore2017078/lech - Container Base Path:
/mnt - Sandboxes Path:
/cfs/klemming/projects/supr/sllstore2017078/lech/singularity_sandboxes
- Local Base Path:
-
Singularity Options:
-b: Bind custom paths for local and container base directories.-B: Bind additional custom paths (same in host and container).-c: Use--cleanenvfor a clean environment.-C: Use--containfor container isolation.
sing.sh [-b] [-B <host_path>] [-c] [-C] <sandbox_name> <command> [options...]-
Bind Paths: The script binds directories between the host and the container.
- By default, it binds the current working directory.
- With
-b, it bindsLOCAL_BASE_PATHtoCONTAINER_BASE_PATH. - With
-B, it binds additional custom paths.
-
Environment Options:
--cleanenv: Clears the container’s environment, using only the provided variables.--contain: Isolates the container from the host system.
-
Run Command: The container is executed using
singularity exec:singularity exec ${SINGULARITY_OPTIONS} --pwd "${CONTAINER_DIR}" "${SANDBOXES_PATH}/${SANDBOX_NAME}" ${COMMAND}
To run an R script within the container:
sing.sh -B /cfs/klemming/ r_archr Rscript "$my_script" --dir "$JOB_NAME" --name "$sample_id" --sample "$sample_path" --threads "$cpus" --gtf "$anno"- Use Docker to create and test your container.
- Push the container to Docker Hub for deployment.
- Pull the container on the Dardel cluster using Singularity.
- Run the container on the cluster using
sing.shscript with appropriate options.
This guide provides instructions on how to configure and use AWS CLI inside a Singularity container, as well as how to pull the container from Docker as a SIF file.
To use the bioinfo_toolkit container, you need to first pull it from Docker and convert it to a SIF (Singularity Image Format) file.
Run the following command:
singularity pull -F bioinfo_toolkit.sif docker://drowsygoat/bioinfo_toolkit:latestThis will download the container as bioinfo_toolkit.sif.
Once you have the SIF file, you can execute AWS commands inside the container.
singularity exec --bind /your/local/path:/your/container/path --pwd /your/container/path bioinfo_toolkit.sif bash- Replace
/your/local/pathwith the directory you want to mount inside the container. - Replace
/your/container/pathwith the working path inside the container.
Alternatively, you can use sing_v2.sh to run it after adding:
export PATH=$PATH:/cfs/klemming/projects/snic/sllstore2017078/kaczma-workingdir/RR/scAnalysis/scripts_chicken_repo/helper_scriptsto your .bashrc (or another shell configuration file).
Run the following command:
sing.sh bioinfo_toolkit aws configureYou will be prompted to enter your AWS credentials:
AWS Access Key ID [None]: <your-access-key>
AWS Secret Access Key [None]: <your-secret-key>
Default region name [None]:
Default output format [None]:
Check that the credentials are saved correctly:
sing.sh bioinfo_toolkit cat ~/.aws/credentialsCheck the configured region:
sing.sh bioinfo_toolkit cat ~/.aws/configTo test an S3 sync operation without making actual changes, use:
sing.sh bioinfo_toolkit aws s3 sync s3://bmkdatarelease-3/delivery_2025022415420100000268/ ./ --dry-runOnce confirmed, run:
sing.sh bioinfo_toolkit aws s3 sync s3://bmkdatarelease-3/delivery_2025022415420100000268/ ./ --exact-timestampsIf you want to log the output of the sync operation for review, run:
sing.sh bioinfo_toolkit aws s3 sync s3://bmkdatarelease-3/delivery_2025022415420100000268/ ./ --dryrun >> ../aws.txtThis will download the files from S3 to your local directory.
Once done, exit the container:
exitor use:
Ctrl + D-
If you encounter issues with modules or dependencies inside the container, try restoring system defaults using:
source /opt/cray/pe/cpe/23.12/restore_lmod_system_defaults.sh