- Containerization is an important technology in bioinformatics because computational analyses often depend on specific software versions, programming languages, libraries, system tools, and configuration settings. A bioinformatics application that works correctly on one computer may fail on another because of differences in operating systems, dependencies, or runtime environments. Containerization helps address these problems by packaging an application and many of its dependencies into a standardized image that can run in a compatible container runtime. Docker and Apptainer, formerly known as Singularity, are widely used technologies for building and running containers in scientific computing. They help researchers create portable environments, simplify software deployment, support collaborative research, and improve the reproducibility of computational workflows.
- A container is an isolated process environment that uses the host operating system’s kernel while providing a defined filesystem, software environment, and execution configuration. Unlike a traditional virtual machine, which typically runs a complete guest operating system on virtualized hardware, a container generally shares the host kernel. Containers are therefore often faster to start and more lightweight than virtual machines, although their resource use depends on the application and configuration. A container can include an executable program, language runtimes, libraries, command-line utilities, configuration files, and other dependencies required by a bioinformatics application.
- Containerization is especially useful because bioinformatics software ecosystems are complex. A genomic analysis pipeline might require Python, R, specific versions of alignment tools, reference-processing utilities, statistical libraries, and system dependencies. Installing every component directly on a shared server can create conflicts between incompatible versions. Containers allow applications to use separately defined software environments, reducing the need to modify the host system and making it easier to deploy the same software stack across development computers, research servers, HPC clusters, and cloud infrastructure.
- A container image is the packaged template from which a container is created. It usually contains a filesystem with the required software and configuration. A container is a running instance of that image, although containers can also be executed as short-lived processes that stop after a command finishes. Images are commonly built from instructions that describe the base environment, software installation steps, files to include, and default execution behavior. The image can then be stored in a registry, transferred to another system, or archived for future use.
- Docker is one of the best-known container platforms. It provides tools for building images, managing containers, connecting storage, and configuring networking. Docker images can be shared through registries such as Docker Hub and other container registries. In bioinformatics, Docker is frequently used for local software development, testing, collaborative projects, automated testing systems, and cloud-based pipelines. Researchers can build a container that includes the tools needed for sequence analysis and then run that container on a computer with Docker installed.
- A Docker installation typically provides the docker command-line interface and a container runtime. Installation methods depend on the operating system and institutional policies. On a personal computer, Docker Desktop may be an option, while Linux servers may use a Docker Engine installation or another compatible container environment. On shared systems, users should follow the administrator’s instructions because access to the Docker daemon can confer substantial privileges. In particular, adding users to the Docker group on many Linux configurations can grant effective root-level control of the host.
- A common way to use Docker is to download a prebuilt image from a trusted registry. For example, a researcher can run:
docker pull ubuntu:24.04
- This command downloads the Ubuntu 24.04 image if it is available from the configured registry. The image is a general operating-system environment rather than a complete bioinformatics application. A container can be started interactively using:
docker run –rm -it ubuntu:24.04 bash
- The –rm option removes the container after it exits, -it provides an interactive terminal, and bash starts a shell inside the container. The image itself remains available locally unless it is explicitly removed. Commands executed inside the container use the container’s filesystem and software environment, subject to the permissions and capabilities provided by the runtime.
- To run an actual bioinformatics application, the image must contain the required program and dependencies. Researchers can either use an appropriate prebuilt image or build a custom image. A prebuilt image is convenient when it is maintained by a trusted project and provides the required version. A custom image offers greater control over dependencies, installation steps, configuration, and default commands. However, custom images require maintenance and should be tested whenever the software stack changes.
- Docker uses a text file called a Dockerfile to define how an image is built. A Dockerfile specifies the base image, working directory, installation commands, files to copy, environment variables, and default execution behavior. For example, the following illustrative Dockerfile creates an environment with FastQC installed through Ubuntu’s package manager:
FROM ubuntu:24.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y –no-install-recommends fastqc && \
rm -rf /var/lib/apt/lists/*
WORKDIR /work
ENTRYPOINT [“fastqc”]
- This example assumes that the selected Ubuntu repositories provide a compatible FastQC package. The installed version may change as repositories are updated, so this Dockerfile alone does not guarantee an identical build indefinitely. For a production research workflow, researchers should record or pin the software version and use a controlled build process. The ENTRYPOINT instruction allows the container to invoke FastQC directly, while WORKDIR defines the default working directory inside the image.
- The image can be built and run using:
docker build -t bioinfo-fastqc:1.0 .
docker run –rm bioinfo-fastqc:1.0 –version
- The docker build command reads the Dockerfile from the current directory and creates an image tagged bioinfo-fastqc:1.0. The second command starts a temporary container and requests the program’s version information. If the program does not support –version, an appropriate documented option should be used instead. Testing the image before using it in a large analysis helps verify that the expected executable is installed and available.
- Containers normally have their own filesystem, so data on the host computer are not automatically accessible at arbitrary locations inside the container. To process biological data, researchers can mount a host directory into the container. For example:
docker run –rm \
-v “$PWD/data:/work/data:ro” \
-v “$PWD/results:/work/results” \
bioinfo-fastqc:1.0 \
/work/data/sample.fastq.gz \
–outdir /work/results
- In this example, the local data directory is mounted at /work/data as read-only, while the results directory is mounted at /work/results for writing. The input file is therefore accessible to the application, but the container cannot normally modify files through the read-only input mount. The output directory must exist on the host before execution. Bind-mount syntax and permission behavior can differ across operating systems, so researchers should test mounts carefully before processing important datasets.
- Container images can also define environment variables, user accounts, labels, health checks, and other settings. These features help organize the execution environment and support automated deployment. For bioinformatics, environment variables may define temporary directories, thread counts, application paths, or configuration locations. However, environment variables alone should not be treated as a complete record of the computational environment. Important software versions, command-line parameters, reference resources, and workflow definitions must also be documented.
- Apptainer is a container platform designed with scientific computing and HPC environments in mind. It was formerly called Singularity, and the name Singularity is still used by some older installations and institutional documentation. Apptainer supports container images that can package scientific applications and their dependencies while allowing users to execute them on shared systems without requiring a conventional Docker daemon. Its execution model is well suited to many research clusters, where users may not have administrator privileges and where security policies restrict privileged container operations.
- Traditional Docker workflows commonly involve a daemon that manages containers and may require elevated privileges or access to a privileged service. Apptainer’s typical HPC workflow instead allows users to run containers directly through the installed runtime, often without root privileges. This makes it attractive for university computing facilities and national research infrastructure. Nevertheless, no container platform is automatically secure under all configurations. Site administrators must still manage permissions, runtime settings, host access, and resource limits appropriately.
- Apptainer can run containers from supported image formats, including images obtained from Docker-compatible registries. For example, a user may run an application directly from a registry using a command such as:
apptainer exec docker://ubuntu:24.04 cat /etc/os-release
- The exec command executes a specified program inside the container. In this example, cat displays information about the operating-system environment packaged in the image. The docker:// prefix tells Apptainer to obtain the image through a Docker-compatible registry interface. Registry access, image caching, supported transports, and network policies depend on the local installation and environment.
- Apptainer can also download or convert a container image into a local image file, commonly using the SIF format, which stands for Singularity Image Format. A SIF file is a container image that can be stored and transferred as a single artifact. For example:
apptainer pull ubuntu.sif docker://ubuntu:24.04
- The command requests a local SIF image based on the specified Ubuntu image. The resulting file can then be used for subsequent container execution without necessarily retrieving the image again, provided the local image and required runtime components remain available. Researchers should verify the provenance and integrity of images before using them in scientific workflows, especially when they contain third-party software.
- Apptainer provides several commands for different execution needs. apptainer exec runs a specified command inside a container, apptainer run invokes the container’s configured runscript, and apptainer shell starts an interactive shell. For example:
apptainer exec ubuntu.sif cat /etc/os-release
apptainer shell ubuntu.sif
- The first command executes cat inside the image, while the second opens a shell for interactive exploration. These operations do not automatically provide the same environment as a full virtual machine. The container typically uses the host kernel and may have access to selected host directories, environment variables, and hardware depending on the runtime configuration.
- A major difference between Docker and Apptainer concerns default filesystem behavior and execution assumptions. Docker generally uses explicit volume mounts to make host data available inside a container. Apptainer commonly binds certain host directories by default, although the exact bind paths depend on configuration and execution mode. This can be convenient on HPC clusters, where users need access to project storage and home directories. However, it also means that researchers must understand which host filesystems are visible and ensure that permissions are appropriate for the data being processed.
- Both Docker and Apptainer can support read-only and writable access to host directories. Researchers should generally protect reference data and original sequencing files from accidental modification. Input directories can be mounted or bound read-only when supported, while output directories should be writable. Temporary data can be directed to appropriate scratch storage. These practices reduce the risk of modifying source data and help separate inputs, intermediate files, and final results.
- One of the principal advantages of containerization is improved portability. A container image can preserve many of the software components needed by an application, making it easier to move a workflow between compatible computing environments. For example, an image containing a particular version of a sequence aligner and its libraries may run on a developer’s computer, an institutional server, and an HPC cluster. However, portability is not absolute. Containers depend on the host kernel, processor architecture, runtime compatibility, available hardware, and permissions. GPU workloads, architecture-specific binaries, and specialized system interfaces may require additional configuration.
- Containerization can also improve reproducibility by reducing variation in software dependencies. A research group can share a container image and use it to execute the same application version with consistent libraries. This is particularly useful when an analysis must be repeated months or years later or transferred to another laboratory. Nevertheless, containers do not automatically make an entire analysis reproducible. Results may still depend on the input data, reference genome, external databases, random seeds, command-line options, CPU or GPU behavior, and other environmental factors.
- For strong reproducibility, researchers should record the exact container image reference, version tag or immutable digest, source repository, build instructions, and relevant workflow parameters. A mutable image tag such as latest can point to different content at different times. Pinning an image by digest or archiving a verified image provides stronger identification of the image used in an analysis. The Dockerfile or other build specification should also be preserved, since a build may change when upstream packages or external downloads change.
- Containerization is particularly valuable in genomics pipelines involving several applications. A workflow may use one container for read quality control, another for alignment, a third for variant calling, and another for annotation. Each container can provide the software dependencies required by its respective stage, reducing conflicts between incompatible tools. Workflow managers such as Snakemake and Nextflow can associate individual rules or processes with container images, enabling automated execution across local computers, HPC clusters, and supported cloud environments.
- In a Snakemake workflow, a rule can specify a container image to be used for a task, provided the workflow is configured to support container execution. Nextflow similarly allows processes to specify container images and can integrate with supported container runtimes. This arrangement separates workflow logic from the underlying software environment. Researchers can update one tool’s container without necessarily changing the environments of unrelated tasks, although workflow compatibility and output formats must still be tested.
- Containerized jobs are often submitted to HPC schedulers such as Slurm or PBS. For example, a Slurm job can execute a command through Apptainer while requesting appropriate CPU, memory, and runtime resources. A simple example is:
#!/usr/bin/env bash
#SBATCH –job-name=container_analysis
#SBATCH –time=01:00:00
#SBATCH –cpus-per-task=2
#SBATCH –mem=4G
#SBATCH –output=container_%j.out
#SBATCH –error=container_%j.err
set -euo pipefail
apptainer exec \
–bind “$PWD/data:/work/data:ro” \
–bind “$PWD/results:/work/results” \
bioinfo-tool.sif \
bioinformatics_tool \
–input /work/data/sample.fasta \
–output /work/results/sample.tsv
- This is a general template rather than a ready-to-run job. The image filename, executable, options, and directory structure must match the actual application and local environment. The input directory should exist and be readable, and the results directory should exist and be writable. Some clusters require additional module loading, project-specific storage paths, or restrictions on image locations. Resource requests should be based on the application’s expected memory, CPU, and runtime requirements rather than the container format itself.
- Container images can become large because they may include operating-system packages, language runtimes, libraries, and scientific software. Researchers should build images efficiently by avoiding unnecessary packages, removing temporary build files, and separating build-time dependencies from runtime dependencies when appropriate. Docker supports multi-stage builds, which can reduce the size of final images by copying only the required runtime artifacts from a build stage. Apptainer images can also be designed to avoid unnecessary software and data. Smaller images generally transfer and cache more efficiently, although image size should not be reduced at the expense of required functionality or transparent dependency management.
- Image layers are another important concept in Docker. Many Docker images are assembled from layers corresponding to build instructions. Layers can be reused and cached, which speeds up repeated builds when earlier steps have not changed. However, poorly structured Dockerfiles can invalidate the cache unnecessarily or preserve large temporary files in earlier layers. Combining related installation commands and removing package caches within the same build step can help reduce image size. Researchers should also avoid placing large biological datasets inside application images unless there is a specific reason to distribute the data together with the software.
- Data and software should usually be managed separately. Reference genomes, FASTQ files, BAM or CRAM files, VCF files, and large annotation databases can be much larger than the application itself. Keeping these data outside the container image allows the same image to be reused across samples and projects. It also makes it easier to update reference datasets independently, control data access, and avoid rebuilding an image whenever a dataset changes. Reference files and databases should be versioned and documented separately so that the exact resources used in an analysis can be identified.
- Container security is an important consideration. Researchers should obtain images from trusted sources, review the image documentation, verify image digests or signatures where available, and avoid executing unknown images with unnecessary privileges. Containers should use the minimum required permissions and access only the host directories needed for the analysis. Secrets such as passwords, access tokens, and private keys should not be embedded in Dockerfiles or images, because they may persist in image layers or become available to anyone who can obtain the image. Sensitive values should instead be provided through approved secret-management mechanisms or protected runtime configuration.
- Containers are not a complete security boundary. Because they share the host kernel, vulnerabilities in the kernel or container runtime may affect isolation. A container may also have broad access to host files if it is given extensive mounts or privileges. Docker configurations that grant access to the Docker daemon can be particularly powerful, while Apptainer’s security properties depend on the runtime version and site configuration. Researchers should follow local security policies and avoid using containers as a reason to bypass access controls or data-governance requirements.
- Performance is another important consideration. Containers generally introduce relatively little overhead for many CPU-based applications, but actual performance depends on the workload, filesystem configuration, networking, runtime, and resource limits. Large data transfers, intensive disk operations, GPU computations, and workloads with many small files can behave differently across environments. On HPC clusters, containerized applications should be benchmarked using representative datasets, and resource usage should be monitored through the scheduler. Some environments require specific options or bind mounts for high-performance storage and GPU access.
- GPU-enabled containers require compatibility between the application, container libraries, host GPU drivers, and supported hardware. The container may include user-space libraries but generally relies on host-level driver support for the device. Apptainer provides GPU-related execution options for supported configurations, while Docker commonly relies on compatible device access and GPU container integration. The exact setup depends on the GPU vendor, driver versions, runtime, and cluster policies. Researchers should follow the system administrator’s instructions and verify GPU visibility and actual application utilization before launching expensive analyses.
- Troubleshooting containerized bioinformatics software often begins with checking whether the image exists, whether the executable is installed, whether the required paths are mounted, and whether the program has sufficient permissions. A missing input file may indicate that the host directory was not mounted at the expected container path. A permission error may indicate that the user inside the container cannot write to the output directory. A missing shared library may indicate that the image was built incorrectly or that the software expects a dependency that was not included. Running the program’s help or version command inside the container can provide a simple initial test.
- Researchers should also distinguish image-building errors from runtime errors. Build failures often arise from unavailable packages, network problems, incompatible compilers, or incorrect installation instructions. Runtime failures may involve malformed input data, incorrect command-line parameters, unavailable mounted files, insufficient resources, or incompatibility with host hardware. Keeping build logs, execution logs, image identifiers, and scheduler records makes these problems easier to diagnose. A minimal test dataset can be used to verify the container before applying it to a large study.
- Container registries support sharing and distributing images. Docker Hub and other registries host images that can be downloaded by users or automated pipelines. Research institutions may also operate private registries to manage internal software. Images should be identified by a clear project name and version, and users should verify that the image comes from the intended publisher. For long-term research, it may be appropriate to archive the image in a managed repository or retain a verified SIF file together with its metadata and build documentation.
- Containers can also be integrated with continuous integration and testing systems. When a software repository changes, an automated pipeline can build the image, run unit tests, and execute a small end-to-end analysis. These checks help identify problems before a new image is used for scientific research. Version tags can distinguish development, testing, and stable releases. For critical workflows, a release should not be considered ready until the image has been tested with representative inputs and the expected outputs have been validated.
- A container image should be treated as part of the scientific record when it materially affects the results. Researchers should retain the image identifier, build recipe, software versions, relevant parameters, and test results. Where appropriate, the image or build specification can be deposited in an institutional repository or linked to a publication and workflow definition. Containerization provides a practical mechanism for preserving software environments, but reproducibility still requires documenting the data, analytical decisions, reference resources, and computational steps.
- Docker and Apptainer/Singularity provide complementary approaches to containerized bioinformatics. Docker is widely used for building, testing, and distributing application images, while Apptainer is particularly useful for executing containers on shared scientific computing systems and HPC clusters. Both approaches can reduce dependency conflicts, simplify software deployment, and improve portability. By selecting trusted images, managing data mounts carefully, pinning software versions, validating outputs, monitoring resources, and documenting container provenance, researchers can develop secure and reproducible workflows for genomics, transcriptomics, proteomics, metagenomics, and other computational biology applications.