Search code examples
devopsnomad

How to keep nomad task from exiting?


In docker we have -t flag to keep containers from exiting. How can achieve the same thing in nomad?

I want to debug if I can ping one service from another, so I just want a container with curl. However, if I try to deploy the ubuntu image specifying it like below it exits and keeps restarting. What can I do so it just keeps running?

task "testubuntu" {

  driver = "docker"

  config {
      image = "ubuntu:latest"
  }

  resources {
      cpu = 500
      memory = 256
      network {
          mbits = 10
      }
  }
}

Solution

  • Add container = true in the config stanza

    task "testubuntu" {
    
      driver = "docker"
    
      config {
          image = "ubuntu:latest"
          container = true
      }
    
      resources {
          cpu = 500
          memory = 256
          network {
              mbits = 10
          }
      }
    }