Nomad job for bash conatiner

Hello,

I am pretty new to nomad. Could someone help me with the nomad job for spinning up a bash container? Any help would really be appreciated.

Hi @arjunlibrian,

The Nomad CLI offers the nomad job init command which can be used to create an example job specification for use. The -short flag will give you a trimmed down useable version also.

The following example specification runs an Ubuntu container with the sleep argument which allows you to access the running container and look around using the nomad alloc exec command.

job "example" {
  datacenters = ["dc1"]

  group "ubuntu" {

    task "sleep" {
      driver = "docker"

      config {
        image = "ubuntu:22.10"
        args  = ["sleep", "infinity"]
      }

      resources {
        cpu    = 500
        memory = 256
      }
    }
  }
}

Thanks,
jrasell and the Nomad team

Thanks for the reply. I was wondering would it be possible to auto-kill the container once there’s no activity, or no active connections for “n” seconds. With infinite sleep the container will stay there forever.

Hi @vikas.saroha,

That is not possible using Nomad natively as Nomad does not have any knowledge of the underlying application running within an allocation. Such functionality would need an external controller to understand the logic and lifecycle of the allocation.

Thanks,
jrasell and the Nomad team