Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can nomad' job from local docker images

Tags:

docker

nomad

nomad docker image will be fetched from Docker Hub.But I have want use some local images.How can I use theme.(I dont want to use private repo)

Example I want to use local image test


> docker images
REPOSITORY                         TAG                 IMAGE ID            CREATED             SIZE
test                        latest              da795ca8a32f        36 minutes ago      567MB
job "test" {
  datacenters = ["dc1"]

  group "example" {
    task "test" {
      driver = "docker"

      config {
        image = "test"
      }

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

It's wrong !

like image 996
zhangslob Avatar asked Mar 04 '23 22:03

zhangslob


2 Answers

I'm not sure if this can be treated as an answer or a "hack".

But if you want Nomad to use docker image that is already present on a node the image MUST NOT be tagged latest.

For testing I tag my images as IMAGE:local. This way Nomad uses it if present, pulls it from remote if not.

like image 184
titus Avatar answered Mar 11 '23 15:03

titus


Looking at Nomad's source code here and here, it seems that using machine local images is not supported. That would make sense, as in a cluster environment with several nodes, the scheduler needs to be able to get the image irrespective of which machine the job is allocated to.

(One possible workaround would be to run a registry service within the Nomad cluster, and use whichever storage backend is most convenient for you)

like image 21
JamesJJ Avatar answered Mar 11 '23 16:03

JamesJJ