Jump to content

Linux/Docker/Variables & Snippets

From Wiki
Revision as of 09:28, 6 January 2025 by Marcluer (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

List all containers and sort by memory consumption

docker stats --no-stream | tail -n +2 | sort -k 4 -h -r

docker stats --no-stream --format "table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}" | tail -n +2 | sort -k 3 -h -r

Docker Host IP

ip -4 route list match 0/0 | cut -d' ' -f3

List all container IPs

docker ps -q | xargs -n 1 docker inspect --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}} {{ .Name }}' | sed 's/ \// /'