Skip to content

Instantly share code, notes, and snippets.

@wojas
Created September 2, 2022 06:52
Show Gist options
  • Save wojas/6c80cd2dd3c04ce91f5a3397f37999ab to your computer and use it in GitHub Desktop.
Save wojas/6c80cd2dd3c04ce91f5a3397f37999ab to your computer and use it in GitHub Desktop.
Check which docker containers are running under qemu emulation on macOS
#!/bin/bash
# https://stackoverflow.com/questions/66834864/how-to-determine-when-docker-containers-on-an-m1-macbook-are-running-via-qemu
#for i in `docker ps --format "{{.Image}}"` ; do
# docker image inspect $i --format "$i -> {{.Architecture}} : {{.Os}}"
#done
OPT=$@
set -euo pipefail
docker container ls $OPT --format "{{.ID}}\t{{.Image}}\t{{.Command}}\t{{.Status}}\t{{.Names}}" |
awk -F '\t' 'BEGIN {OFS=FS} { "docker image inspect --format \"{{.Os}}/{{.Architecture}}\" "$2" #"NR | getline $6; print }' |
/opt/homebrew/opt/util-linux/bin/column --table --table-columns "CONTAINER ID,IMAGE,COMMAND,STATUS,NAME,ARCH" -o ' ' -s $'\t'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment