简体   繁体   English

如何从Vagrant中的隐私AWS ECR存储库中获取Docker映像

[英]How to get docker images from privacy AWS ECR repository in Vagrant

I found that you can use Vagrant and Docker as a provider, That I think is so cool. 我发现您可以使用Vagrant和Docker作为提供程序,我认为这很酷。 Official doc 官方文件

The documentation shows a section to set up using private repositories. 该文档显示了使用私有存储库进行设置的部分。 email, username, password and auth_server 电子邮件,用户名,密码和auth_server

I want to know if Vagrant supports aws ecr get-login to get docker images from AWS Registry? 我想知道Vagrant是否支持aws ecr get-login从AWS Registry获得docker镜像?

Edited: 编辑:

I tried this: 我尝试了这个:

Vagrant.configure("2") do |config|
  config.vm.define "mydocker" do |a|
    a.vm.provider "docker" do |d|
      d.image = "my-account.dkr.ecr.us-east-1.amazonaws.com/myimage:latest"

      #Private registry
      d.email = "my@emai.com"
      d.username = "my-user"
      d.password = "my-pass"
      d.auth_server = "my-account.dkr.ecr.us-east-1.amazonaws.com"

      #Custom Docker Host
      d.vagrant_machine = "dockerhost"
      d.vagrant_vagrantfile = "./dockerHost/Vagrantfile"
    end
  end
end

This is the output error: (Vagrant tried to make the login with the parameters) 这是输出错误:(Vagrant尝试使用参数进行登录)

Command: "docker" "login" "-u" "my-user" "-p" "my-pass" "my-account.dkr.ecr.us-east-1.amazonaws.com"

Stderr: Error response from daemon: login attempt to https://my-account.dkr.ecr.us-east-1.amazonaws.com/v2/ failed with status: 401 Unauthorized

Thanks. 谢谢。

I found the way using get-authorization-token I don't know it is the best way, but it works by the moment. 我找到了使用get-authorization-token我不知道这是最好的方法,但是目前它是可行的。

The get-authorization-token command creates a valid token for 12 hours. get-authorization-token命令将创建一个有效的令牌,持续12小时。 (I think this can be changed) and you can see the official doc (我认为可以更改),您可以看到官方文档

If you are on MAC More info (does`t work with zsh console, so uses bash) 如果您使用的是MAC 更多信息 (不能与zsh控制台一起使用,请使用bash)

aws ecr get-authorization-token --output text --query authorizationData[].authorizationToken | base64 -D | cut -d: -f2

It will print the decode password and then in the Vagrantfile: 它将打印解码密码,然后在Vagrantfile中:

...
  #Private registry
  d.email = ""
  d.username = "AWS"
  d.password = "The-decoded-password"
  d.auth_server = "my-account.dkr.ecr.us-east-1.amazonaws.com"
...

And it works. 而且有效。

Maybe it is necessary to generate a password that live more than 12 hours =0) 也许有必要生成一个有效期超过12小时的密码= 0)

I will waiting for comments or improvements. 我将等待评论或改进。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从 AWS EC2 上的 AWS ECR 中提取图像而不使用 docker login 但使用 EC2 Instance 角色和 ECR 存储库权限 - Pull images from AWS ECR on AWS EC2 without using docker login but using EC2 Instance role and ECR repository permissions 如何让 Docker Swarm 管理器使用 IAM 角色权限从 AWS ECR 中提取图像? - How do I get a Docker Swarm manager to pull images from AWS ECR using IAM Role permissions? 是否可以在ECR(aws docker注册表)存储库中获取标签历史记录? - is it possible to get the tag history in an ECR (the aws docker registry) repository? 将 Docker 镜像上传到 AWS ECR - Uploading Docker Images to AWS ECR 如何通过 cloudformation 删除包含图像的 aws ECR 存储库? - How to delete aws ECR repository which contain images through cloudformation? AWS ECR Repository - 如何从一个账户复制图像并推送到另一个账户 - AWS ECR Repository - How to copy images from one account and push to another account 无法将Docker映像从Windows 10推送到AWS ECR - Unable to push docker images into AWS ECR from Windows 10 我能否将我的 docker 存储库或图像从 Amazon ECR 直接移动到不同账户上的另一个 ECR 存储库? - Am I able to move my docker repositories or images from Amazon ECR directly to another ECR repository on a different account? 如何将Docker容器映像更新从AWS ECR部署到ECS? - How to deploy docker container image updates from AWS ECR to ECS? 如何从 Gitlab CI 登录 AWS ECR 以下载 Docker 映像 - How to login to AWS ECR from Gitlab CI to download a Docker image
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM