How would you run container like this?

There are many examples how to run docker containers from command like or using helm. Yet when I find guide like this GitHub - keycloak/keycloak-containers: Docker image for Keycloak project I wonder how would you convert run command to nomad a config?

To run Keycloak, run:
docker run quay.io/keycloak/keycloak start-dev

My config:

job "keycloak" {
  datacenters = ["aws"]
  type        = "service"

  group "keycloak" {
    network {
      port "keycloak" { to = 9090 }
    }

    task "keycloak" {
      driver = "docker"

        config {
          image = "https://quay.io/keycloak/keycloak:latest"
          ports = ["keycloak"]
        }

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

Hi @vladman,

That docker run command also has start-dev at the end (i.e. is an argument to the keycloak image).

In Nomad you would specify this using args in the docker task config. This job file should serve as a working example. Note the memory requirement needed to be higher than what you provided above - Java apps use a lot of memory.

job "keycloak" {
  datacenters = ["dc1"]
  type        = "service"

  group "keycloak" {
    network {
      port "keycloak" { to = 9090 }
    }

    task "keycloak" {
      driver = "docker"

      config {
        image = "https://quay.io/keycloak/keycloak:latest"
        args  = ["start-dev"]
        ports = ["keycloak"]
      }

      resources {
        cpu    = 1000
        memory = 1024
      }
    }
  }
}
2 Likes