本文介绍了如何运行 Docker 检查以获取 ECR 注册表中图像的图像元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 ECR 注册表的相关访问权限,但是我无法通过运行 Docker inspect 命令来获取图像元数据.我正在尝试

I have the relevant access to the ECR registry however i am not able to get image meta data by running the Docker inspect command. I am trying with

docker inspect ecrregistryurl/dockerimage:imageversion

推荐答案

更新

正如@Tarun 所提到的,我尝试了它,但它没有给我与 docker inspect 相同的输出.这是文档中的链接.https://docs.aws.amazon.com/AmazonECR/最新/用户指南/Registries.html#registry_auth_http

As mentioned by @Tarun I tried it but it's not giving me the same output as docker inspect. Here is the link from the documentation.https://docs.aws.amazon.com/AmazonECR/latest/userguide/Registries.html#registry_auth_http

#!/bin/bash
TOKEN=$(aws ecr get-authorization-token --output text --query authorizationData[].authorizationToken)
curl -i -H "Authorization: Basic $TOKEN" https://account_id.dkr.ecr.us-west-2.amazonaws.com/v2/redis/manifests/latest 

但是检查输出它与 docker inspect 不同.

But check the output it's different from docker inspect.

Docker inspect image_name

此命令只会检查您的本地图像,而不是您的注册表.

This command will only inspect your local images instead of your Registry.

如何仅获取提供 ECR 的相关元数据.

What you can do to get only relevant metadata that provides ECR.

aws ecr list-images --repository-name redis

它会给你一个图片标签和图片ID.

It will give you an image tag and image id.

aws ecr describe-images --repository-name redis

这将提供这个名为 redis 的 repo 中的所有图像和更多细节.

This will give all the image and some more detail in this repo named redis.

现在,对于 docker inspect,首先拉取图像.

aws ecr get-login --no-include-email

运行此命令的输出.您将使用令牌获得登录信息.

run the output of this command. You will get a login using the token.

docker pull account_id.dkr.ecr.us-west-2.amazonaws.com/redis:latest

然后运行

docker pull account_id.dkr.ecr.us-west-2.amazonaws.com/redis:latest

你会得到你想要的.

或者,如果您已经在某个 ec2 实例上运行此映像,则在该 ec2 实例上运行您将获得所需的结果.

Or if you already running this image at some ec2 instance then run on that ec2 instance you will get the desired result.

docker inspect account_id.dkr.ecr.us-west-2.amazonaws.com/redis:latest

https://docs.aws.amazon.com/cli/latest/reference/ecr/index.html

这篇关于如何运行 Docker 检查以获取 ECR 注册表中图像的图像元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 07:07