如何在 Windows 上使用 AWS CLI 列出图像标签

huangapple go评论70阅读模式
英文:

how to list image tags using aws cli on windows

问题

I'm trying to list the image tags from ECR repo using the following command on Windows:

aws ecr list-images --repository-name plat | jq '.imageIds | map(.imageTag) | sort | .[]' | sort -r | head -1

I installed the jq utility; however, it says 'map' is not recognized as an internal or external command.

I tried a lot to find the map utility for Windows but did not succeed. How can I make this entire command work on Windows? It worked perfectly on Linux.

Is there any workaround? Do we have any equivalent command on Windows? Please suggest.

UPDATE 1

On Windows

C:\Users\ik\Downloads>aws ecr list-images --repository-name plat | jq '.imageIds | map(.imageTag) | sort | .[]' | sort -r | head -1
'map' is not recognized as an internal or external command,
operable program or batch file.
PS C:\Users\ik\Downloads>

On Linux

root@CSX-Ik:~# aws ecr list-images --repository-name plat | jq '.imageIds | map (.imageTag) | sort | .[]' | sort -r | head -1
"19617.1"
root@CSX-Ik:~#

UPDATE 2

PS C:\Users\ik\Downloads> aws ecr list-images --repository-name plat
{
    "imageIds": [
        {
            "imageDigest": "sha256:5fd06c0b6c6349324343232432429e8bf6b1ce62d810c2eef1eca",
            "imageTag": "20230421.001"
        },
        {
            "imageDigest": "sha256:d7a28e9e62c5465465465469080eeae6a8308c99ec032a845119202f6d427ef8",
            "imageTag": "33345.1"
        },
        {
            "imageDigest": "sha256:681ae17a52a4c673cc8c62d50823432432432432432432497789879c37a4",
            "imageTag": "3445.2"
        },
        {
            "imageDigest": "sha256:ff7090d214ac72334323243209809809803e8af",
            "imageTag": "33456.1"
        }
    ]
}
]

After putting map equivalent

C:\Users\ik\Downloads>aws ecr list-images --repository-name plat | jq '.imageIds | [.[] | .imageTag] | sort | .[]' | sort -r | head -1
'[.[]' is not recognized as an internal or external command,
operable program or batch file.
PS C:\Users\ik\Downloads>
英文:

Im trying to list the image tags from ECR repo using below command on windows

aws ecr list-images --repository-name plat   | jq '.imageIds   | map (.imageTag)  | sort | .[]'   | sort -r   | head -1

I installed jq utility , however , it says 'map' is not recognized as an internal or external command,

i tried lot finding map utility for windows but did not get . how can I make this entire command work on windows ? it worked perfectly on linux.

any workaround ?
do we have any equivalent command on windows ? please suggest

UPDATE 1

on windows

C:\Users\ik\Downloads>aws ecr list-images --repository-name plat   | jq '.imageIds   | map (.imageTag)  | sort | .[]'   | sort -r   | head -1
'map' is not recognized as an internal or external command,
operable program or batch file.
PS C:\Users\ik\Downloads>

on linux

root@CSX-Ik:~# aws ecr list-images --repository-name plat | jq '.imageIds | map (.imageTag)|sort|.[]' | sort -r | head -1
"19617.1"
root@CSX-Ik:~#

UPDATE 2

PS C:\Users\ik\Downloads> aws ecr list-images --repository-name plat
{
    "imageIds": [
        {
            "imageDigest": "sha256:5fd06c0b6c6349324343232432429e8bf6b1ce62d810c2eef1eca",
            "imageTag": "20230421.001"
        },
        {
            "imageDigest": "sha256:d7a28e9e62c5465465465469080eeae6a8308c99ec032a845119202f6d427ef8",
            "imageTag": "33345.1"
        },
        {
            "imageDigest": "sha256:681ae17a52a4c673cc8c62d50823432432432432432432497789879c37a4",
            "imageTag": "3445.2"
        },
        {
            "imageDigest": "sha256:ff7090d214ac72334323243209809809803e8af",
            "imageTag": "33456.1"
        }
}
]
}

after putting map equivalent

C:\Users\ik\Downloads>aws ecr list-images --repository-name plat   | jq '.imageIds   | [.[]   | .imageTag]   | sort | .[]'   | sort -r   | head -1
'[.[]' is not recognized as an internal or external command,
operable program or batch file.
PS C:\Users\ik\Downloads> 

答案1

得分: 0

使用AWS CLI的内置--query参数。这是您需要的命令:

aws ecr list-images --repository-name plat --query 'imageIds[].imageTag' --output text
英文:

Use the built in --query parameter of AWS cli. So this is what you need:

aws ecr list-images --repository-name plat --query 'imageIds[].imageTag' --output text

答案2

得分: 0

以下是您要翻译的内容:

在Windows上的命令如下:

对于Windows:

powershell.exe aws ecr list-images --repository-name <repo-name> | jq '.imageIds | map (.imageTag) | sort | reverse | first'

在此处也提到了相同的内容:

https://eduwebmonster.com/how-to-list-aws-ecr-images-with-latest-tag-on-windows-and-linux/

英文:

here is the command on windows

For Windows :

powershell.exe aws ecr list-images --repository-name &lt;repo-name&gt; | jq &#39;.imageIds | map (.imageTag) | sort | reverse | first&#39;&quot;

same is mentioned here

https://eduwebmonster.com/how-to-list-aws-ecr-images-with-latest-tag-on-windows-and-linux/

huangapple
  • 本文由 发表于 2023年6月15日 21:16:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/76482895.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定