Skip to content

Apptainer not working in container #633

@JulianFlesch

Description

@JulianFlesch

While playing around with the devcontainer image, I noticed the apptainer installation does not seem to work as expected, even though it is supposed to be installed as a local feature.

Issue

Here is how to reproduce the error:

$ docker run --rm -it ghcr.io/nextflow-io/training:latest bash
root ➜ / $ apptainer
bash: apptainer: command not found
root ➜ / $ find / -name apptainer

Even though the feature shows up in the container metadata:

$ docker inspect ghcr.io/nextflow-io/training:latest | grep devcontainer.metadata
 "devcontainer.metadata": [ 
    {'id': 'ghcr.io/devcontainers/features/common-utils:2'}
    {'id': 'ghcr.io/devcontainers/features/git:1', 'customizations': {'vscode': {'settings': 
    {'github.copilot.chat.codeGeneration.instructions': [{'text': 'This dev container includes an up-to-date version of Git, built from source as needed, pre-installed and available on the `PATH`.'}]}}}}
    {'remoteUser': 'vscode'}
>>>>{'id': '../local-features/apptainer'}<<<<
    {'id': '../local-features/init'}
    {'id': '../local-features/tower-agent'}
    {'id': 'ghcr.io/devcontainers/features/docker-outside-of-docker:1', 'securityOpt': ['label=disable'], 'entrypoint': '/usr/local/share/docker-init.sh', 'mounts': [{'source': '/var/run/docker.sock', 'target': '/var/run/docker-host.sock', 'type': 'bind'}], 'customizations': {'vscode': {'extensions': ['ms-azuretools.vscode-docker'], 'settings': 
    {'github.copilot.chat.codeGeneration.instructions': [{'text': 'This dev container includes the Docker CLI (`docker`) pre-installed and available on the `PATH` for running and managing containers using the Docker daemon on the host machine.'}]}}}}
    {'id': 'ghcr.io/devcontainers/features/java:1', 'customizations': {'vscode': {'extensions': ['vscjava.vscode-java-pack'], 'settings': {'java.import.gradle.java.home': '/usr/local/sdkman/candidates/java/current'}}}}
    {'id': 'ghcr.io/rocker-org/devcontainer-features/miniforge:2'}
    {'id': 'ghcr.io/va-h/devcontainers-features/uv'}
    {'id': '../local-features/conda-channels'}
    {'id': '../local-features/nextflow'}
    {'id': '../local-features/uv-tools'}
    {'onCreateCommand': 'bash .devcontainer/setup.sh', 'customizations': {'vscode': {'extensions': ['nf-core.nf-core-extensionpack'], 'settings': {'python.defaultInterpreterPath': '/opt/conda/bin/python'}, 'terminal.integrated.defaultProfile.linux': 'bash'}}, 'remoteUser': 'root', 'remoteEnv': {'NXF_HOME': '/workspaces/.nextflow', 'NXF_EDGE': '0', 'NXF_VER': '24.10.4', 'HOST_PROJECT_PATH': '/workspaces/training', 'SHELL': '/bin/bash'}}
 ],

Suggested Change

This is likely because the install.sh of the local feature (here) fails silently.

$ docker run --rm -it ghcr.io/nextflow-io/training:latest /bin/bash add-apt-repository -
y ppa:apptainer/ppa
/bin/bash: add-apt-repository: No such file or directory

I don't understand why this would not show in the build logs, but changing the bash script to first install software-properties-common seems to fix it:

#!/usr/bin/env bash

# Install Apptainer (Singularity)

apt-get update --quiet

# installs add-apt-repository
apt install --reinstall -y software-properties-common

add-apt-repository -y ppa:apptainer/ppa

apt install -y apptainer

apt-get clean
rm -rf /var/lib/apt/lists/*

My Setup

  • Docker version 28.0.1, build 068a01ea94
  • MacOS Darwin Kernel (architecture: arm64)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions