How to change the default docker registry in HashiCorp nomad

1.4k Views Asked by At

I want to change the default docker registry configuration in nomad. I am setting up a nomad cluster in enterprise VM, which connects to frog artifcatory docker registry. Any docker hub images reference has to go through the internal artifactory registry.

But when I setup nomad and try to install waypoint inside nomad, it looks for busy box and waypoint server and runner images from docker hub.

How can I change the configuration for nomad to go via artifactory to reach docker hub?

4

There are 4 best solutions below

0
On

It's not possible to set a "default" registry for the Nomad client's Docker driver. The registry would need to be set in the "image" configuration of the Nomad jobspec's "config" stanza. Within that config stanza, or on the Nomad client, you would need to provide an "auth" stanza as well so that Nomad can pull the image from your private registry.

https://www.nomadproject.io/docs/drivers/docker

Regarding Waypoint specifically, for your requirements, I'd recommend installing Waypoint not with the waypoint install command, because there isn't an option to change the Docker repository from which the busy box image is used. Instead, I'd recommend creating a custom Nomad jobspec to deploy Waypoint, and if you intend to use busy box as part of that jobspec, then to specify your image repository in Artifactory that way.

0
On

I have asked the same question in nomad forums and got an answer for this. I am posting and adding link to the suggested answer here.

https://discuss.hashicorp.com/t/nomad-network-bridge/37421/2

You can configure Nomad to use an alternate image by configuring the infra_image under the Docker plugin options in Nomad’s agent configuration.

   

 plugin "docker" {
  config {
    infra_image: "<local mirror>/google_containers/pause-amd64:3.1"
  }
}

1
On
task "example" {
  driver = "docker"

  config {
    image = "secret/service"

    auth {
      username = "dockerhub_user"
      password = "dockerhub_password"
    }
  }
}
0
On

If you want to pull images from private repository, then you can follow official documentation: https://developer.hashicorp.com/nomad/docs/drivers/docker#authentication

Just configure your task as follows:

task "example" {
  driver = "docker"

  config {
    image = "secret/service"

    auth {
      username = "dockerhub_user"
      password = "dockerhub_password"
    }
  }
}