Linux command
apptainer-shell 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Start an interactive shell
apptainer shell [container.sif]
Open shell with bound directory
apptainer shell --bind [/host/path]:[/container/path] [container.sif]
Shell into a Docker Hub image
apptainer shell docker://[ubuntu:latest]
Start shell with NVIDIA GPU support
apptainer shell --nv [container.sif]
Open shell with clean environment
apptainer shell --cleanenv [container.sif]
Shell with full containment
apptainer shell --containall [container.sif]
Start shell with writable overlay
apptainer shell --overlay [overlay.img] [container.sif]
Shell with fakeroot privileges
apptainer shell --fakeroot [container.sif]
说明
apptainer shell starts an interactive shell session inside an Apptainer container. This provides a command-line environment within the container for exploration, debugging, and interactive work. By default, the shell inherits your user identity, home directory, and current working directory. The host environment is largely preserved unless containment options are used. This makes the shell feel familiar while providing access to the container's filesystem and installed software. The container can be specified as a local SIF file, a Docker reference (docker://), a library reference (library://), or an OCI archive. The default shell is /bin/sh but can be overridden with the --shell option if the container has other shells available. For development work, combine --overlay or --writable-tmpfs to allow temporary modifications within the container. Use --fakeroot when operations require apparent root privileges without actual host root access.
参数
- --bind, -B _src:dest[:opts]_
- Bind mount a host path into the container.
- --overlay _image_
- Use overlay filesystem for writable layer.
- --nv
- Enable NVIDIA GPU support.
- --rocm
- Enable AMD ROCm GPU support.
- --contain, -c
- Use minimal /dev and empty other directories.
- --containall, -C
- Full containment with clean environment and PID namespace.
- --cleanenv, -e
- Clean environment before starting shell.
- --env _VAR=value_
- Set environment variable in container.
- --home _path_
- Set custom home directory.
- --pwd _path_
- Initial working directory in container.
- --fakeroot
- Run with fake root privileges.
- --net
- Enable network namespace.
- --shell _path_
- Specify shell to use (default: /bin/sh).
- --writable-tmpfs
- Add writable tmpfs overlay.
- --no-home
- Do not bind the home directory.
FAQ
What is the apptainer-shell command used for?
apptainer shell starts an interactive shell session inside an Apptainer container. This provides a command-line environment within the container for exploration, debugging, and interactive work. By default, the shell inherits your user identity, home directory, and current working directory. The host environment is largely preserved unless containment options are used. This makes the shell feel familiar while providing access to the container's filesystem and installed software. The container can be specified as a local SIF file, a Docker reference (docker://), a library reference (library://), or an OCI archive. The default shell is /bin/sh but can be overridden with the --shell option if the container has other shells available. For development work, combine --overlay or --writable-tmpfs to allow temporary modifications within the container. Use --fakeroot when operations require apparent root privileges without actual host root access.
How do I run a basic apptainer-shell example?
Run `apptainer shell [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-shell?
Bind mount a host path into the container.