github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/website/content/plugins/drivers/community/singularity.mdx (about)

     1  ---
     2  layout: docs
     3  page_title: 'Drivers: Singularity'
     4  description: >-
     5    The Singularity task driver is used to run application containers using
     6    Singularity.
     7  ---
     8  
     9  # Singularity Driver
    10  
    11  Name: `Singularity`
    12  
    13  The `Singularity` driver provides an interface for using Singularity for running application
    14  containers. You can download the external Singularity driver [here][singularity-driver].
    15  
    16  ## Task Configuration
    17  
    18  ```hcl
    19  task "lolcow" {
    20    driver = "Singularity"
    21  
    22    config {
    23       # this example run an image from sylabs container library with the
    24       # canonical example of lolcow
    25       image = "library://sylabsed/examples/lolcow:latest"
    26       # command can be run, exec or test
    27       command = "run"
    28    }
    29  }
    30  ```
    31  
    32  The `Singularity` driver supports the following configuration in the job spec:
    33  
    34  - `image` - The Singularity image to run. It can be a local path or a supported URI.
    35  
    36    ```hcl
    37    config {
    38      image = "library://sylabsed/examples/lolcow:latest"
    39    }
    40    ```
    41  
    42  - `verbose` - (Optional) Enables extra verbosity in the Singularity runtime logging.
    43    Defaults to `false`.
    44  
    45    ```hcl
    46    config {
    47      verbose = "false"
    48    }
    49    ```
    50  
    51  - `debug` - (Optional) Enables extra debug output in the Singularity runtime
    52    logging. Defaults to `false`.
    53  
    54    ```hcl
    55    config {
    56      debug = "false"
    57    }
    58    ```
    59  
    60  - `command` - Singularity command action; can be `run`, `exec` or `test`.
    61  
    62    ```hcl
    63    config {
    64      command = "run"
    65    }
    66    ```
    67  
    68  - `args` - (Optional) Singularity command action arguments, when trying to pass arguments to `run`, `exec` or `test`.
    69    Multiple args can be given by a comma separated list.
    70  
    71    ```hcl
    72    config {
    73      args = [ "echo", "hello Cloud" ]
    74    }
    75    ```
    76  
    77  - [`binds`][bind] - (Optional) A user-bind path specification. This spec has the format `src[:dest[:opts]]`, where src and
    78    dest are outside and inside paths. If dest is not given, it is set equal to src.
    79    Mount options ('opts') may be specified as 'ro' (read-only) or 'rw' (read/write, which
    80    is the default). Multiple bind paths can be given by a comma separated list.
    81  
    82    ```hcl
    83    config {
    84      bind = [ "host/path:/container/path" ]
    85    }
    86    ```
    87  
    88  - [`overlay`][overlay] - (Optional) Singularity command action flag, to enable an overlayFS image for persistent data
    89    storage or as read-only layer of container. Multiple overlay paths can be given by a comma separated list.
    90  
    91    ```hcl
    92    config {
    93      overlay = [ "host/path/to/overlay" ]
    94    }
    95    ```
    96  
    97  - [`security`][security] - (Optional) Allows the root user to leverage security modules such as
    98    SELinux, AppArmor, and seccomp within your Singularity container.
    99    You can also change the UID and GID of the user within the container at runtime.
   100  
   101    ```hcl
   102    config {
   103      security = [ "uid:1000 " ]
   104    }
   105    ```
   106  
   107  - `contain` - (Optional) Use minimal `/dev` and empty other directories (e.g. `/tmp` and `$HOME`) instead of sharing filesystems from your host.
   108  
   109    ```hcl
   110    config {
   111      contain = "false"
   112    }
   113    ```
   114  
   115  - `workdir` - (Optional) Working directory to be used for `/tmp`, `/var/tmp` and `$HOME` (if -c/--contain was also used).
   116  
   117    ```hcl
   118    config {
   119      workdir = "/path/to/folder"
   120    }
   121    ```
   122  
   123  - `pwd` - (Optional) Initial working directory for payload process inside the container.
   124  
   125    ```hcl
   126    config {
   127      pwd = "/path/to/folder"
   128    }
   129    ```
   130  
   131  ## Networking
   132  
   133  Currently the `Singularity` driver only supports host networking. For more detailed instructions on how to set up networking options, please refer to the `Singularity` user guides [singularity-network]
   134  
   135  ## Client Requirements
   136  
   137  The `Singularity` driver requires the following:
   138  
   139  - 64-bit Linux host
   140  - The `linux_amd64` Nomad binary
   141  - The Singularity driver binary placed in the [plugin_dir][plugin_dir] directory.
   142  - [`Singularity`][singularity] v3.1.1+ to be installed
   143  
   144  ## Plugin Options ((#plugin_options))
   145  
   146  - `enabled` - The `Singularity` driver may be disabled on hosts by setting this option to `false` (defaults to `true`).
   147  
   148  - `singularity_cache` - The location in which all containers are stored (commonly defaults to `/var/lib/singularity`). See [`Singularity-cache`][singularity-cache] for more details.
   149  
   150  An example of using these plugin options with the new [plugin
   151  syntax][plugin] is shown below:
   152  
   153  ```hcl
   154  plugin "nomad-driver-Singularity" {
   155    config {
   156      enabled = true
   157      singularity_path = "/var/lib/singularity"
   158    }
   159  }
   160  ```
   161  
   162  Please note the plugin name should match whatever name you have specified for the external driver in the [plugin_dir][plugin_dir] directory.
   163  
   164  ## Client Attributes
   165  
   166  The `Singularity` driver will set the following client attributes:
   167  
   168  - `driver.singularity` - Set to `1` if Singularity is found and enabled on the host node.
   169  - `driver.singularity.version` - Version of `Singularity` e.g.: `3.1.0`.
   170  
   171  ## Resource Isolation
   172  
   173  This driver supports CPU and memory isolation via the `Singularity` cgroups feature. Network
   174  isolation is supported via `--net` and `--network` feature (Singularity v3.1.1+ required).
   175  
   176  [singularity-driver]: https://github.com/sylabs/nomad-driver-singularity
   177  [singularity_man]: https://linuxcontainers.org/Singularity/manpages/man5/Singularity.container.conf.5.html#lbAM
   178  [plugin]: /docs/configuration/plugin
   179  [plugin_dir]: /docs/configuration#plugin_dir
   180  [plugin-options]: #plugin_options
   181  [singularity]: https://github.com/sylabs/singularity
   182  [singularity-cache]: https://www.sylabs.io/guides/3.1/user-guide/appendix.html#c
   183  [bind]: https://www.sylabs.io/guides/3.1/user-guide/bind_paths_and_mounts.html
   184  [security]: https://www.sylabs.io/guides/3.1/user-guide/security_options.html
   185  [overlay]: https://www.sylabs.io/guides/3.1/user-guide/persistent_overlays.html
   186  [singularity-network]: https://www.sylabs.io/guides/3.1/user-guide/networking.html