github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/website/pages/docs/drivers/external/podman.mdx (about)

     1  ---
     2  layout: docs
     3  page_title: 'Drivers: podman'
     4  sidebar_title: Podman
     5  description: >-
     6    The Podman task driver uses podman (https://podman.io/) for containerizing
     7    tasks.
     8  ---
     9  
    10  # Podman Task Driver
    11  
    12  Name: `podman`
    13  
    14  Homepage: https://github.com/pascomnet/nomad-driver-podman
    15  
    16  The podman task driver plugin for Nomad uses the [Pod Manager (podman)][podman]
    17  daemonless container runtime for executing Nomad tasks. Podman supports OCI
    18  containers and its command line tool is meant to be [a drop-in replacement for
    19  Docker's][podman-cli].
    20  
    21  See the project's [homepage][homepage] for details.
    22  
    23  ## Client Requirements
    24  
    25  - Linux host with [`podman`][podman] installed.
    26  - [`nomad-driver-podman`][releases] binary in Nomad's [`plugin_dir`][plugin_dir].
    27  
    28  You need a varlink enabled podman binary and a system socket activation unit, see https://podman.io/blogs/2019/01/16/podman-varlink.html.
    29  
    30  Since the Nomad agent, nomad-driver-podman plugin binary, and podman will
    31  reside on the same host, skip the ssh aspects of the podman varlink
    32  documentation above.
    33  
    34  ## Task Configuration
    35  
    36  Due to Podman's similarity to Docker, the example job created by [`nomad init -short`][nomad-init] is easily adapted to use Podman instead:
    37  
    38  ```hcl
    39  job "example" {
    40    datacenters = ["dc1"]
    41  
    42    group "cache" {
    43      task "redis" {
    44        driver = "podman"
    45  
    46        config {
    47          image = "docker://redis:3.2"
    48  
    49          port_map {
    50            db = 6379
    51          }
    52        }
    53  
    54        resources {
    55          cpu    = 500
    56          memory = 256
    57  
    58          network {
    59            mbits = 10
    60            port  "db"  {}
    61          }
    62        }
    63      }
    64    }
    65  }
    66  ```
    67  
    68  - `image` - The image to run.
    69  
    70  ```hcl
    71  config {
    72    image = "docker://redis"
    73  }
    74  ```
    75  
    76  - `command` - (Optional) The command to run when starting the container.
    77  
    78  ```hcl
    79  config {
    80    command = "some-command"
    81  }
    82  ```
    83  
    84  - `args` - (Optional) A list of arguments to the optional command. If no
    85    _command_ is specified, the arguments are passed directly to the container.
    86  
    87  ```hcl
    88  config {
    89    args = [
    90      "arg1",
    91      "arg2",
    92    ]
    93  }
    94  ```
    95  
    96  - `volumes` - (Optional) A list of `host_path:container_path` strings to bind
    97    host paths to container paths.
    98  
    99  ```hcl
   100  config {
   101    volumes = [
   102      "/some/host/data:/container/data"
   103    ]
   104  }
   105  ```
   106  
   107  - `tmpfs` - (Optional) A list of `/container_path` strings for tmpfs mount
   108    points. See `podman run --tmpfs` options for details.
   109  
   110  ```hcl
   111  config {
   112    tmpfs = [
   113      "/var"
   114    ]
   115  }
   116  ```
   117  
   118  - `hostname` - (Optional) The hostname to assign to the container. When
   119    launching more than one of a task (using count) with this option set, every
   120    container the task starts will have the same hostname.
   121  
   122  - `init` - Run an init inside the container that forwards signals and reaps processes.
   123  
   124  ```hcl
   125  config {
   126    init = true
   127  }
   128  ```
   129  
   130  - `init_path` - Path to the container-init binary.
   131  
   132  ```hcl
   133  config {
   134    init = true
   135    init_path = "/usr/libexec/podman/catatonit"
   136  }
   137  ```
   138  
   139  - `user` - Run the command as a specific user/uid within the container. See
   140    [task configuration][task].
   141  
   142  - `memory_reservation` - Memory soft limit (unit = b (bytes), k (kilobytes), m
   143    (megabytes), or g (gigabytes))
   144  
   145  After setting memory reservation, when the system detects memory contention or
   146  low memory, containers are forced to restrict their consumption to their
   147  reservation. So you should always set the value below --memory, otherwise the
   148  hard limit will take precedence. By default, memory reservation will be the
   149  same as memory limit.
   150  
   151  ```hcl
   152  config {
   153    memory_reservation = "100m"
   154  }
   155  ```
   156  
   157  - `memory_swap` - A limit value equal to memory plus swap. The swap limit
   158    should always be larger than the [memory value][memory-value].
   159  
   160  Unit can be b (bytes), k (kilobytes), m (megabytes), or g (gigabytes). If you
   161  don't specify a unit, b is used. Set LIMIT to -1 to enable unlimited swap.
   162  
   163  ```hcl
   164  config {
   165    memory_swap = "180m"
   166  }
   167  ```
   168  
   169  - `memory_swappiness` - Tune a container's memory swappiness behavior. Accepts
   170    an integer between 0 and 100.
   171  
   172  ```hcl
   173  config {
   174    memory_swappiness = 60
   175  }
   176  ```
   177  
   178  ## Networking
   179  
   180  Podman supports forwarding and exposing ports like Docker. See [Docker Driver
   181  configuration][docker-ports] for details.
   182  
   183  ## Plugin Options
   184  
   185  The podman plugin has options which may be customized in the agent's
   186  configuration file.
   187  
   188  - `volumes` stanza:
   189  
   190    - `enabled` - Defaults to `true`. Allows tasks to bind host paths (volumes)
   191      inside their container.
   192    - `selinuxlabel` - Allows the operator to set a SELinux label to the
   193      allocation and task local bind-mounts to containers. If used with
   194      `volumes.enabled` set to false, the labels will still be applied to the
   195      standard binds in the container.
   196  
   197  ```hcl
   198  plugin "nomad-driver-podman" {
   199    config {
   200      volumes {
   201        enabled      = true
   202        selinuxlabel = "z"
   203      }
   204    }
   205  }
   206  ```
   207  
   208  - `gc` stanza:
   209  
   210    - `container` - Defaults to `true`. This option can be used to disable
   211      Nomad from removing a container when the task exits.
   212  
   213  ```hcl
   214  plugin "nomad-driver-podman" {
   215    config {
   216      gc {
   217        container = false
   218      }
   219    }
   220  }
   221  ```
   222  
   223  - `recover_stopped` - Defaults to `true`. Allows the driver to start and reuse
   224    a previously stopped container after a Nomad client restart.
   225    Consider a simple single node system and a complete reboot. All previously managed containers
   226    will be reused instead of disposed and recreated.
   227  
   228  ```hcl
   229  plugin "nomad-driver-podman" {
   230    config {
   231      recover_stopped = false
   232    }
   233  }
   234  ```
   235  
   236  [docker-ports]: /docs/drivers/docker#forwarding-and-exposing-ports
   237  [homepage]: https://github.com/pascomnet/nomad-driver-podman
   238  [memory-value]: /docs/job-specification/resources#memory
   239  [nomad-init]: /docs/commands/job/init
   240  [plugin_dir]: /docs/configuration#plugin_dir
   241  [podman]: https://podman.io/
   242  [podman-cli]: https://podman.io/whatis.html
   243  [releases]: https://github.com/pascomnet/nomad-driver-podman/releases
   244  [task]: /docs/job-specification/task#user