docker images

built-in
0.0% Savings
0 Commands
0 Tokens saved
4 Tests

Install

tokf install 4a66a4fa6f6b2ea0e53976a53970fee14e0db2ec79ff23aff5cac94aecfe70ea
Safety checks passed

Filter definition

command = "docker images"
run = "docker images --format '{{.Repository}}:{{.Tag}}\t{{.Size}}' {args}"
passthrough_args = ["--format"]
skip = ["^<none>:<none>"]

[lua_script]
lang = "luau"
source = '''
if exit_code ~= 0 then return nil end
local repos = {}
local order = {}
for line in output:gmatch("[^\n]+") do
  local repo_tag, size = line:match("^(.+)\t(.+)$")
  if repo_tag then
    local repo, tag = repo_tag:match("^(.+):(.+)$")
    if repo and tag then
      if not repos[repo] then
        repos[repo] = { tags = {}, size = size }
        table.insert(order, repo)
      end
      table.insert(repos[repo].tags, tag)
      repos[repo].size = size
    end
  end
end
if #order == 0 then return "No images" end
local lines = {}
for _, repo in ipairs(order) do
  local e = repos[repo]
  table.insert(lines, repo .. ": " .. table.concat(e.tags, ", ") .. " (" .. e.size .. ")")
end
return table.concat(lines, "\n")
'''

[on_failure]
tail = 10

Examples

dangling images are skipped ~9 tokens → ~5 tokens (44% saved)
Raw output
<none>:<none>	1.2GB
nginx:latest	187MB
Filtered output
nginx: latest (187MB)
no images shows message ~0 tokens → ~2 tokens
Raw output
 
Filtered output
No images
daemon error shows tail ~24 tokens → ~24 tokens
Raw output
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Filtered output
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
groups images by repository ~37 tokens → ~33 tokens (11% saved)
Raw output
ubuntu:22.04	77.8MB
ubuntu:20.04	72.8MB
nginx:latest	187MB
nginx:1.24	185MB
postgres:15	412MB
redis:7-alpine	30MB
node:20-slim	220MB
node:18-slim	210MB
Filtered output
ubuntu: 22.04, 20.04 (72.8MB)
nginx: latest, 1.24 (185MB)
postgres: 15 (412MB)
redis: 7-alpine (30MB)
node: 20-slim, 18-slim (210MB)
Warning: Community filters are third-party code. Review the filter definition above before installing it in production environments.
Browse all filters