skip to Main Content

I own a Mac M1 and I run Docker on it.
On OSX, Docker can run native ARM images but also emulate x86/amd64 to run images that were not built for ARM.

My question is simple: From the command line, I am trying to find an extension of the command ‘docker image ls’ which displays the image platform.

$ docker image ls

REPOSITORY TAG PLATFORM IMAGE ID CREATED SIZE
………………………..arm64
………………………..x86

I already saw this answer: How to filter Docker images by platform? but it does NOT answer the question. OS and PLATFORM are two different things.

Thank you

2

Answers


  1. Try to combine docker image with jq :

    docker image inspect $(docker images -q) | jq -r '.[] | select(.Architecture=="arm64").RepoTags[]'
    
    Login or Signup to reply.
  2. Is this what you looking for?

    docker image inspect --format "{{.ID}} {{.RepoTags}} {{.Architecture}}" $(docker image ls -q)
    

    output:

    sha256:fb495265b81ffaa0d3bf8887231b954a1139b2e3d611c3ac3ddeaff72313909c [postgres:10.11-alpine] amd64
    

    Explanation:

    • $(docker image ls -q) → pass all image IDs as parameters to inspect command
    • docker image inspect print detailed info about image

    Also it is possible to add pipe with grep, like {inspect command} | egrep 'amd64$' to print only amd64 architecture for example

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search