• Overview
    • Batch Processing Workloads
    • Edge Workload Management
    • Non-Containerized Application Orchestration
    • Simple Container Orchestration
  • Enterprise
  • Tutorials
  • Docs
  • API
  • Plugins
  • Tools
  • Community
GitHub—Stars on GitHub
Download
    • v1.3.x (latest)
    • v1.2.x
    • v1.1.x
    • v1.0.x
    • v0.12.x
    • v0.11.x
    • Overview
    • Quickstart
      • Overview
      • Requirements
      • Reference Architecture
      • Deployment Guide
    • Windows Service
    • Overview
    • Specific Version Details
    • Overview
    • Consul
    • Consul Service Mesh
    • Vault Integration

    • Overview
    • Architecture
      • Overview
      • Base
      • Task Drivers
      • Devices
      • Storage
      • Overview
      • Internals
      • Preemption
    • Consensus Protocol
    • Filesystem
    • Gossip Protocol
    • Security Model
    • Overview
    • acl
    • audit
    • autopilot
    • client
    • consul
    • plugin
    • sentinel
    • search
    • server
    • server_join
    • telemetry
    • tls
    • ui
    • vault
    • Overview
      • Overview
      • bootstrap
      • policy apply
      • policy delete
      • policy info
      • policy list
      • token create
      • token delete
      • token info
      • token list
      • token self
      • token update
    • agent
    • agent-info
      • Overview
      • exec
      • fs
      • logs
      • restart
      • signal
      • status
      • stop
      • Overview
      • validate
      • Overview
      • fail
      • list
      • pause
      • promote
      • resume
      • status
      • unblock
      • Overview
      • list
      • status
      • Overview
      • allocs
      • deployments
      • dispatch
      • eval
      • history
      • init
      • inspect
      • plan
      • periodic force
      • promote
      • revert
      • run
      • scale
      • scaling-events
      • status
      • stop
      • validate
      • Overview
      • get
    • monitor
      • Overview
      • apply
      • delete
      • inspect
      • list
      • status
      • Overview
      • config
      • drain
      • eligibility
      • status
      • Overview
      • api
      • autopilot get-config
      • autopilot set-config
      • debug
      • keygen
      • keyring
      • metrics
      • raft info
      • raft list-peers
      • raft logs
      • raft remove-peer
      • raft state
      • snapshot agent
      • snapshot inspect
      • snapshot restore
      • snapshot save
      • snapshot state
      • Overview
      • status
      • Overview
      • apply
      • delete
      • init
      • inspect
      • list
      • status
      • Overview
      • apply
      • dismiss
      • info
      • list
      • Overview
      • policy info
      • policy list
      • Overview
      • apply
      • delete
      • list
      • read
      • Overview
      • force-leave
      • join
      • members
      • Overview
      • service delete
      • service info
      • service list
    • status
      • Overview
      • gc
      • reconcile summaries
    • ui
    • version
      • Overview
      • create
      • delete
      • deregister
      • detach
      • init
      • register
      • snapshot create
      • snapshot delete
      • snapshot list
      • status

    • Overview
      • Overview
      • Expressions
        • Overview
          • chunklist
          • coalesce
          • coalescelist
          • compact
          • concat
          • contains
          • distinct
          • element
          • flatten
          • index
          • keys
          • length
          • lookup
          • merge
          • range
          • reverse
          • setintersection
          • setproduct
          • setunion
          • slice
          • sort
          • values
          • zipmap
          • can
          • convert
          • try
          • bcrypt
          • md5
          • rsadecrypt
          • sha1
          • sha256
          • sha512
          • formatdate
          • timeadd
          • base64decode
          • base64encode
          • csvdecode
          • jsondecode
          • jsonencode
          • urlencode
          • yamldecode
          • yamlencode
          • abspath
          • basename
          • dirname
          • file
          • fileexists
          • fileset
          • pathexpand
          • cidrhost
          • cidrnetmask
          • cidrsubnet
          • cidrsubnets
          • abs
          • ceil
          • floor
          • log
          • max
          • min
          • parseint
          • pow
          • signum
          • chomp
          • format
          • formatlist
          • indent
          • join
          • lower
          • regex_replace
          • replace
          • split
          • strrev
          • substr
          • title
          • trim
          • trimprefix
          • trimspace
          • trimsuffix
          • upper
          • uuidv4
          • uuidv5
      • Locals
      • Syntax
      • Variables
    • artifact
    • affinity
    • check_restart
    • connect
    • constraint
    • csi_plugin
    • device
    • dispatch_payload
    • env
    • ephemeral_disk
    • expose
    • gateway
    • group
    • job
    • lifecycle
    • logs
    • meta
    • migrate
    • multiregion
    • network
    • parameterized
    • periodic
    • proxy
    • reschedule
    • resources
    • restart
    • scaling
    • service
    • sidecar_service
    • sidecar_task
    • spread
    • task
    • template
    • update
    • upstreams
    • vault
    • volume
    • volume_mount
    • Overview
      • Overview
      • capability
      • mount_options
      • topology_request
    • Overview
    • Docker
    • Isolated Fork/Exec
    • Java
    • Podman
    • QEMU
    • Raw Fork/Exec
      • Overview
      • containerd
      • Firecracker driver
      • Jailtask driver
      • Lightrun
      • LXC
      • Pot
      • Rkt Deprecated
      • Rookout
      • Singularity
      • systemd-nspawn
      • Windows IIS
      • Overview
      • ECS
    • Overview
      • Overview
      • Nvidia
      • USB Beta
  • Schedulers
    • Overview
    • Runtime Environment
    • Variable Interpolation
    • Overview
      • Overview
      • apm
      • dynamic_application_sizing
      • http
      • nomad
      • policy
      • policy_eval
      • source
      • strategy
      • target
      • telemetry
    • API
    • CLI
    • Policy
    • Telemetry
      • Overview
        • Overview
        • Datadog
        • Nomad API
        • Prometheus
        • Overview
        • Dynamic Application Sizing Average
        • Dynamic Application Sizing Max
        • Dynamic Application Sizing Percentile
        • Fixed Value
        • Pass-Through
        • Target Value
        • Threshold
        • Overview
        • Amazon Web Services Autoscaling Group
        • Azure Virtual Machine Scale Set
        • Dynamic Application Sizing
        • Google Cloud Engine Managed Instance Group
        • Nomad Task Group
      • Community
      • Overview
      • Checks
      • Node Selector Strategy
        • Overview
        • Base
        • APM
        • Strategy
        • Target
    • Overview
    • Operating Nomad Agents
    • Monitoring Nomad
    • Metrics Reference
    • Cluster Management
    • Transport Security
    • Access Control

    • Overview
    • Alternative to Kubernetes
    • Supplement to Kubernetes
  • Nomad Ecosystem
  • Nomad Partnerships
  • Who Uses Nomad
    • Overview
      • Overview
      • FAQ
  • FAQ
Type '/' to Search

»restart Stanza

Placementjob -> group -> restart
job -> group -> task -> restart

The restart stanza configures a tasks's behavior on task failure. Restarts happen on the client that is running the task.

job "docs" {
  group "example" {
    restart {
      attempts = 3
      delay    = "30s"
    }
  }
}
job "docs" {
  group "example" {
    restart {
      attempts = 3
      delay    = "30s"
    }
  }
}

If specified at the group level, the configuration is inherited by all tasks in the group, including any sidecar tasks. If also present on the task, the policy is merged with the restart policy from the encapsulating task group.

For example, assuming that the task group restart policy is:

restart {
  interval = "30m"
  attempts = 2
  delay    = "15s"
  mode     = "fail"
}
restart {
  interval = "30m"
  attempts = 2
  delay    = "15s"
  mode     = "fail"
}

and the individual task restart policy is:

restart {
  attempts = 5
}
restart {
  attempts = 5
}

then the effective restart policy for the task will be:

restart {
  interval = "30m"
  attempts = 5
  delay    = "15s"
  mode     = "fail"
}
restart {
  interval = "30m"
  attempts = 5
  delay    = "15s"
  mode     = "fail"
}

Because sidecar tasks don't accept a restart block, it's recommended that you set the restart for jobs with sidecar tasks at the task level, so that the Connect sidecar can inherit the default restart.

»restart Parameters

  • attempts (int: <varies>) - Specifies the number of restarts allowed in the configured interval. Defaults vary by job type, see below for more information.

  • delay (string: "15s") - Specifies the duration to wait before restarting a task. This is specified using a label suffix like "30s" or "1h". A random jitter of up to 25% is added to the delay.

  • interval (string: <varies>) - Specifies the duration which begins when the first task starts and ensures that only attempts number of restarts happens within it. If more than attempts number of failures happen, behavior is controlled by mode. This is specified using a label suffix like "30s" or "1h". Defaults vary by job type, see below for more information.

  • mode (string: "fail") - Controls the behavior when the task fails more than attempts times in an interval. For a detailed explanation of these values and their behavior, please see the mode values section.

»restart Parameter Defaults

The values for many of the restart parameters vary by job type. Here are the defaults by job type:

  • The default batch restart policy is:

    restart {
      attempts = 3
      delay    = "15s"
      interval = "24h"
      mode     = "fail"
    }
    
    restart {
      attempts = 3
      delay    = "15s"
      interval = "24h"
      mode     = "fail"
    }
    
  • The default service and system job restart policy is:

    restart {
      interval = "30m"
      attempts = 2
      delay    = "15s"
      mode     = "fail"
    }
    
    restart {
      interval = "30m"
      attempts = 2
      delay    = "15s"
      mode     = "fail"
    }
    

»mode Values

This section details the specific values for the "mode" parameter in the Nomad job specification for constraints. The mode is always specified as a string:

restart {
  mode = "..."
}
restart {
  mode = "..."
}
  • "delay" - Instructs the client to wait until another interval before restarting the task.

  • "fail" - Instructs the client not to attempt to restart the task once the number of attempts have been used. This is the default behavior. This mode is useful for non-idempotent jobs which are unlikely to succeed after a few failures. The allocation will be marked as failed and the scheduler will attempt to reschedule the allocation according to the reschedule stanza.

»restart Examples

With the following restart block, a failing task will restart 3 times with 15 seconds between attempts, and then wait 10 minutes before attempting another 3 attempts. The task restart will never fail the entire allocation.

restart {
  attempts = 3
  delay    = "15s"
  interval = "10m"
  mode     = "delay"
}
restart {
  attempts = 3
  delay    = "15s"
  interval = "10m"
  mode     = "delay"
}

With the following restart block, a task that that fails after 1 minute, after 2 minutes, and after 3 minutes will be restarted each time. If it fails again before 10 minutes, the entire allocation will be marked as failed and the scheduler will follow the group's reschedule specification, possibly resulting in a new evaluation.

restart {
  attempts = 3
  delay    = "15s"
  interval = "10m"
  mode     = "fail"
}
restart {
  attempts = 3
  delay    = "15s"
  interval = "10m"
  mode     = "fail"
}
github logoEdit this page
DocsAPIResourcesPrivacySecurityPress KitConsent Manager