← 返回命令列表

Linux command

apptainer-run 命令

文本

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

常用示例

Run the default action

apptainer run [container.sif]

Run a container

apptainer run [container.sif] [arg1] [arg2]

Run from Docker Hub

apptainer run --bind [/data]:[/mnt/data] docker://[python:3.11] [script.py]

Run with NVIDIA GPU support

apptainer run --nv [container.sif]

Run with isolated environment

apptainer run --containall [container.sif]

Run with writable overlay

apptainer run --overlay [overlay.img] [container.sif]

Run as fakeroot

apptainer run --fakeroot [container.sif]

Run with custom environment variables

apptainer run --env [KEY=value] [container.sif]

说明

apptainer run executes the default runscript of an Apptainer container. The runscript is defined in the container's %runscript section during build and typically contains the container's primary function or entrypoint. This differs from apptainer exec which runs an arbitrary command. When you run a container, Apptainer invokes the runscript as if it were a regular executable, passing any additional command-line arguments to it. Containers can be specified as local SIF files, Docker references (docker://), library references (library://), or OCI archives. If the container has no runscript defined, the command will execute a shell. The run command supports SCIF (Scientific Filesystem) apps via the --app flag, allowing containers to bundle multiple applications with separate entry points. Standard bind mounts, environment variables, and GPU support work identically to other Apptainer commands.

参数

--bind, -B _src:dest[:opts]_
Bind mount a host path into the container.
--overlay _image_
Use an overlay image for a writable layer.
--nv
Enable NVIDIA GPU support.
--rocm
Enable AMD ROCm GPU support.
--contain, -c
Use minimal /dev and empty home/tmp directories.
--containall, -C
Full containment with clean environment.
--cleanenv, -e
Clean environment before running.
--env _VAR=value_
Set environment variable.
--home _path_
Specify custom home directory.
--pwd _path_
Set working directory inside container.
--fakeroot
Run with fake root privileges.
--net
Enable network namespace.
--writable-tmpfs
Add writable tmpfs overlay.
--app _name_
Run a specific SCIF app within the container.
--no-home
Do not bind the home directory.

FAQ

What is the apptainer-run command used for?

apptainer run executes the default runscript of an Apptainer container. The runscript is defined in the container's %runscript section during build and typically contains the container's primary function or entrypoint. This differs from apptainer exec which runs an arbitrary command. When you run a container, Apptainer invokes the runscript as if it were a regular executable, passing any additional command-line arguments to it. Containers can be specified as local SIF files, Docker references (docker://), library references (library://), or OCI archives. If the container has no runscript defined, the command will execute a shell. The run command supports SCIF (Scientific Filesystem) apps via the --app flag, allowing containers to bundle multiple applications with separate entry points. Standard bind mounts, environment variables, and GPU support work identically to other Apptainer commands.

How do I run a basic apptainer-run example?

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

What does --bind, -B _src:dest[:opts]_ do in apptainer-run?

Bind mount a host path into the container.