Sidharth R
  • Home
  • Posts
  • Journal
  • Home
  • Posts
  • Journal
  • Search

Snippets

One-line commands for Linux, Docker and Kubernetes, each with a short note on what it does and what it will change, so you can copy one and run it.

Docker

Delete all stopped containers

docker container prune -f

Frees disk on a build box. Each container's writable layer goes with it; volumes are kept.

Remove dangling images

docker image prune -f

Only untagged layers left behind by rebuilds, so it is safe to run anywhere.

List every container with its IP address

docker ps -q | xargs docker inspect \
  --format '{{ .Name }} {{ range $net, $conf := .NetworkSettings.Networks }}{{ $net }}={{ $conf.IPAddress }} {{ end }}'

For reaching one container from another by address. With nothing running, xargs still runs inspect and it errors — GNU xargs -r skips it.

All Docker snippets →

Kubernetes

Decode one key in a secret

kubectl get secret <name> -o jsonpath='{.data.<key>}' | base64 -d

The value lands in your terminal and its scrollback — not while screen sharing. macOS before Ventura spells it -D.

Delete all failed and evicted pods

kubectl delete pods -A --field-selector=status.phase=Failed

Clears the Evicted rows left by node pressure. Their logs go too, so save anything you still need.

Decode every key in a secret

kubectl get secret <name> -o go-template='{{range $k, $v := .data}}{{$k}}: {{$v | base64decode}}{{"\n"}}{{end}}'

One line per key, when you don't know what the secret holds.

All Kubernetes snippets →

Linux

Find the largest files in a directory

find . -type f -exec du -h {} + | sort -rh | head -n 20

Run it before deleting anything. du reports space on disk, so sparse files look smaller than ls says.

See which process is listening on a port

sudo ss -tulpn

Without sudo the process column is empty for other users' sockets, which reads as nothing listening.

Follow a systemd service's logs live

journalctl -u nginx -f

Ctrl+C stops it. A service that writes its own log file will not appear here.

All Linux snippets →

  • Home
  • Posts
  • Journal
  • Labs
  • Snippets
  • Quotes
  • Links worth your time
  • About
  • Contact
  • Style guide
  • RSS

© 2026 Sidharth R. · Licensed CC BY-NC-SA 4.0