← 返回命令列表

Linux command

apptainer-test 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Run the test script

apptainer test [container.sif]

Test a Docker Hub image

apptainer test docker://[image:tag]

Test a specific app

apptainer test --app [appname] [container.sif]

Test with bound directory

apptainer test --bind [/data]:[/mnt] [container.sif]

Test with NVIDIA GPU support

apptainer test --nv [container.sif]

说明

apptainer test executes the test script defined in a container's %test section. This provides a standardized way for container authors to include validation checks that verify the container is functioning correctly. Test scripts typically check that required software is installed, libraries are accessible, and the container can perform its intended function. The exit code of the test script determines pass (0) or fail (non-zero) status. For containers using the Scientific Filesystem (SCIF), the --app flag runs the test section of a specific application within the container. This allows multi-app containers to have independent test suites. Container authors define tests during build time. If no %test section exists, the command completes successfully without executing anything. This command is useful in CI/CD pipelines to validate container builds before deployment.

参数

--app _name_
Run the test section of a specific SCIF app.
--bind, -B _src:dest[:opts]_
Bind mount a host path into the container.
--nv
Enable NVIDIA GPU support.
--rocm
Enable AMD ROCm GPU support.
--contain, -c
Use minimal /dev and empty other directories.
--containall, -C
Full containment mode.
--cleanenv, -e
Clean environment before testing.
--fakeroot
Run test with fake root privileges.
--cwd, --pwd _path_
Set working directory inside container.
--writable, -w
Make file system accessible as read-write.
--writable-tmpfs
Make file system read-write with non-persistent data (tmpfs overlay).
--help, -h
Display help for the test command.

FAQ

What is the apptainer-test command used for?

apptainer test executes the test script defined in a container's %test section. This provides a standardized way for container authors to include validation checks that verify the container is functioning correctly. Test scripts typically check that required software is installed, libraries are accessible, and the container can perform its intended function. The exit code of the test script determines pass (0) or fail (non-zero) status. For containers using the Scientific Filesystem (SCIF), the --app flag runs the test section of a specific application within the container. This allows multi-app containers to have independent test suites. Container authors define tests during build time. If no %test section exists, the command completes successfully without executing anything. This command is useful in CI/CD pipelines to validate container builds before deployment.

How do I run a basic apptainer-test example?

Run `apptainer test [container.sif]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --app _name_ do in apptainer-test?

Run the test section of a specific SCIF app.