apptainer instance run

Run a named instance of the given container image

Synopsis

The instance run command allows you to create a new named instance from an existing container image that will begin running in the background. If a runscript is defined in the container metadata the commands in that script will be executed with the instance run command as well. You can optionally pass arguments to runscript.

NOTE: This command was added to Apptainer significantly later than the other action commands and will not work with older containers. In that case, you may need to rebuild the container.

apptainer instance run accepts the following container formats

.sif - Singularity Image Format (SIF)

Native to Singularity 3.0+ and all Apptainer versions.

.sqsh - SquashFS format

Native to Singularity 2.4+ and < 3.0.

.img - ext3 format

Native to Singularity versions < 2.4.

directory/ - sandbox format

Directory containing a valid root file system and optionally Apptainer meta-data.

instance://

A local running instance of a container. See the instance command group.

library://

A SIF container hosted on a Library (no library enabled by default).

docker://

A Docker/OCI container hosted on Docker Hub or another OCI registry.

shub://

A container hosted on Singularity Hub.

oras://

A SIF container hosted on an OCI registry that supports the OCI Registry As Storage (ORAS) specification.

ipfs://

A SIF image from an IPFS cluster, using a HTTP gateway.

apptainer instance run [start options...] <container path> <instance name> [runscript args...]

Examples

$ apptainer instance run /tmp/my-sql.sif mysql

$ apptainer shell instance://mysql
Apptainer my-sql.sif> pwd
/home/mibauer/mysql
Apptainer my-sql.sif> ps
PID TTY          TIME CMD
  1 pts/0    00:00:00 appinit
  2 pts/0    00:00:00 bash
  3 pts/0    00:00:00 ps
Apptainer my-sql.sif>

$ apptainer instance stop /tmp/my-sql.sif mysql
Stopping /tmp/my-sql.sif mysql

Options

    --add-caps string                 a comma separated capability list to add
    --allow-setuid[=true|false]       allow setuid binaries in container (root only)
    --app string                      set an application to run inside a container
    --apply-cgroups string            apply cgroups from file for container processes (root only)
    --authfile string                 Docker-style authentication file to use for writing/reading OCI registry credentials
    --basepath string                 comma-separated paths to search for the base image of an overlay-only image (built with 'apptainer build --overlay'); the last path may be an oras:// or docker:// image reference matching original transport
-B, --bind stringArray                a user-bind path specification.  spec has the format src[:dest[:opts]], where src and dest are outside and inside paths.  If dest is not given, it is set equal to src.  Mount options ('opts') may be specified as 'ro' (read-only) or 'rw' (read/write, which is the default). Multiple bind paths can be given by a comma separated list.
    --blkio-weight int                Block IO relative weight in range 10-1000, 0 to disable
    --blkio-weight-device strings     Device specific block IO relative weight
    --boot[=true|false]               execute /sbin/init to boot container (root only)
-e, --cleanenv[=true|false]           clean environment before running container
    --compat[=true|false]             apply settings for increased OCI/Docker compatibility. Infers --containall, --no-init, --no-umask, --no-eval, --writable-tmpfs.
    --compat32[=true|false]           additionally bind the 32-bit GPU libraries into /.singularity.d/libs32, for 32-bit programs in the container (requires --nv or --rocm)
-c, --contain[=true|false]            use minimal /dev and empty other directories (e.g. /tmp and $HOME) instead of sharing filesystems from your host
-C, --containall[=true|false]         contain not only file systems, but also PID, IPC, and environment
    --cpu-shares int                  CPU shares for container (default -1)
    --cpus string                     Number of CPUs available to container
    --cpuset-cpus string              List of host CPUs available to container
    --cpuset-mems string              List of host memory nodes available to container
    --disable-cache[=true|false]      do not use or create cache
    --dmtcp-launch string             checkpoint for dmtcp to save container process state to (experimental)
    --dmtcp-restart string            checkpoint for dmtcp to use to restart container process (experimental)
    --dns string                      list of DNS server separated by commas to add in resolv.conf
    --docker-host string              specify a custom Docker daemon host
    --docker-login[=true|false]       login to a Docker Repository interactively
    --drop-caps string                a comma separated capability list to drop
    --env stringToString              pass environment variable to contained process (default [])
    --env-file strings                pass environment variables from file to contained process
-f, --fakeroot[=true|false]           run container with the appearance of running as root
    --fusemount strings               A FUSE filesystem mount specification of the form '<type>:<fuse command> <mountpoint>' - where <type> is 'container' or 'host', specifying where the mount will be performed ('container-daemon' or 'host-daemon' will run the FUSE process detached). <fuse command> is the path to the FUSE executable, plus options for the mount. <mountpoint> is the location in the container to which the FUSE mount will be attached. E.g. 'container:sshfs 10.0.0.1:/ /sshfs'. Implies --pid.
-h, --help[=true|false]               help for run
-H, --home string                     a home directory specification.  spec can either be a src path or src:dest pair.  src is the source path of the home directory outside the container and dest overrides the home directory within the container. (default "/home/runner")
    --hostname string                 set container hostname
    --intel-hpu[=true|false]          enable Intel(R) Gaudi accelerator support while using a minimal /dev
-i, --ipc[=true|false]                run container in a new IPC namespace
    --keep-privs[=true|false]         let root user keep privileges in container (root only)
    --memory string                   Memory limit in bytes
    --memory-reservation string       Memory soft limit in bytes
    --memory-swap string              Swap limit, use -1 for unlimited swap
    --mount stringArray               a mount specification e.g. 'type=bind,src=/opt,dst=/hostopt'.
-n, --net[=true|false]                run container in a new network namespace (sets up a bridge network interface by default)
    --netns-path string               join the network namespace at the specified path (as root, or if permitted in apptainer.conf)
    --network string                  specify desired network type separated by commas, each network will bring up a dedicated interface inside container
    --network-args strings            specify network arguments to pass to CNI plugins
    --no-env strings                  list of environment variables to block from import into container from host environment
    --no-eval[=true|false]            do not shell evaluate env vars or OCI container CMD/ENTRYPOINT/ARGS
    --no-home[=true|false]            do NOT mount users home directory if /home is not the current working directory
    --no-https[=true|false]           use http instead of https for docker:// oras:// and library://<hostname>/... URIs
    --no-init[=true|false]            do NOT start shim process with --pid
    --no-mount strings                disable one or more 'mount xxx' options set in apptainer.conf and/or specify absolute destination path to disable a bind path entry, or 'bind-paths' to disable all bind path entries.
    --no-privs[=true|false]           drop all privileges from root user in container
    --no-umask[=true|false]           do not propagate umask to the container, set default 0022 umask
    --nv[=true|false]                 enable Nvidia support
    --nvccli[=true|false]             use nvidia-container-cli for GPU setup (experimental)
    --oom-kill-disable[=true|false]   Disable OOM killer
-o, --overlay strings                 use an overlayFS image for persistent data storage or as read-only layer of container
    --passphrase[=true|false]         prompt for an encryption passphrase
    --pem-path string                 enter an path to a PEM formatted RSA key for an encrypted container
    --pid-file string                 write instance PID to the file with the given name
    --pids-limit int                  Limit number of container PIDs, use -1 for unlimited
    --rocm[=true|false]               enable experimental Rocm support
    --runscript-timeout string        set the timeout duration for runscript (default 1m)
-S, --scratch strings                 include a scratch directory within the container that is linked to a temporary dir (use -W to force location)
    --security strings                enable security features (SELinux, Apparmor, Seccomp)
    --unsquash[=true|false]           Convert SIF file to temporary sandbox before running
-u, --userns[=true|false]             run container in a new user namespace
    --uts[=true|false]                run container in a new UTS namespace
-W, --workdir string                  working directory to be used for /tmp, /var/tmp and $HOME (if -c/--contain was also used)
-w, --writable[=true|false]           by default all Apptainer containers are available as read only. This option makes the file system accessible as read/write.
    --writable-tmpfs[=true|false]     makes the file system accessible as read-write with non persistent data (with overlay support only)

SEE ALSO

Auto generated by spf13/cobra on 1-Dec-2026