【问题标题】:nomad: Pull docker image from ECR with AWS Access and Secret keysnomad:使用 AWS 访问密钥和密钥从 ECR 拉取 docker 映像
【发布时间】:2018-01-22 00:13:15
【问题描述】:

我的问题

我已经使用来自 Dockerhub 的默认 Redis 映像在 AWS 上成功部署了一个带有几十个 Redis Docker 容器的游牧作业。

我稍微更改了nomad init 创建的默认配置文件以更改运行容器的数量,一切都按预期工作

问题是我要运行的实际图像在ECR,这需要AWS权限(访问和密钥),我不知道如何发送这些。

代码

job "example" {
  datacenters = ["dc1"]
  type = "service"
  update {
    max_parallel = 1
    min_healthy_time = "10s"
    healthy_deadline = "3m"
    auto_revert = false    
    canary = 0
  }    
  group "cache" {
    count = 30    
    restart {
      attempts = 10
      interval = "5m"    
      delay = "25s"    
      mode = "delay"
    }    
    ephemeral_disk {    
      size = 300
    }    
    task "redis" {
      driver = "docker"    
      config {

    # My problem here

    image = "https://-whatever-.dkr.ecr.us-east-1.amazonaws.com/-whatever-"
        port_map {
          db = 6379
        }
      }
      resources {
        network {
          mbits = 10
          port "db" {}
        }
      }
      service {
        name = "global-redis-check"
        tags = ["global", "cache"]
        port = "db"
        check {
          name     = "alive"
          type     = "tcp"
          interval = "10s"
          timeout  = "2s"
        }
      }
    }
  }
}

我尝试了什么

  • 广泛的 Google 搜索
  • 阅读the manual
  • aws 凭据放在运行nomad 文件的机器中(使用aws configure

我的问题

如何配置 nomad 以使用 AWS 凭证从 AWS ECR 拉取 Docker 容器?

【问题讨论】:

  • 有趣的是,这个问题没有得到解答,谷歌搜索在前 5 个结果中显示了这个问题。此外,您的声誉假设您知道阅读文档,因此问题并非没有事先研究。人们仍在寻找这个。

标签: amazon-iam amazon-ecr nomad


【解决方案1】:

对您来说已经很晚了,但是 aws ecr 并没有以 docker 期望的方式处理身份验证。在那里你需要运行 sudo $(aws ecr get-login --no-include-email --region ${your region}) 运行返回的命令实际上以符合 docker 的方式进行身份验证

请注意,如果配置了 aws cli,则区域是可选的。就我个人而言,我在盒子中分配了一个 IAM 角色(允许 ecr pull/list/etc),这样我就不必手动处理凭证。

【讨论】:

    【解决方案2】:

    我不使用 ECR,但如果它像普通的 docker 注册表一样,这就是我为我的注册表所做的,它可以工作。假设前面的句子,它应该也适合你:

    config {
                    image = "registry.service.consul:5000/MYDOCKERIMAGENAME:latest"
                    auth {
                        username = "MYMAGICUSER"
                        password = "MYMAGICPASSWORD"
                    }
                }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-10
      • 2020-12-14
      • 2020-07-21
      • 2017-10-02
      • 2019-12-07
      • 2014-09-12
      相关资源
      最近更新 更多