API: `docker top` ignores the ps arguments (`ps_args`)

Open
#348 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
docker, rust

Research direction

Start at the daemon handler for GET /containers/{id}/top and trace how it handles ps_args; compare that path with the Docker Engine API behavior described in the issue. The report includes no source file or test names, so first locate the endpoint and its tests. Done means supported arguments such as aux and -eo pid,rss,args affect the returned process columns, or unsupported arguments return an error.

Written by the indexing model from the issue text.

Description

Kiri version and system
  • Kiri 0.2.1 (engine 27.5.1), docker CLI 29.9.3
  • macOS 27.2, Apple M4 Pro
  • ~/.kiri/vm.json: {"cpus":6,"memory_mib":16384}
What you did
docker run -d -i --name top-a busybox:1.37 cat
docker top top-a
docker top top-a aux
docker top top-a -eo pid,rss,args
curl --unix-socket ~/.kiri/run/docker.sock 'http://localhost/v1.47/containers/top-a/top?ps_args=aux'
What happened

All three docker top commands print the same default columns, and the API answers the same for ps_args=aux, so the arguments are dropped in the daemon, not in the CLI:

UID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD
root                22838               1                   0                   05:43               ?                   00:00:00            cat
{"Processes":[["root","22838","1","0","05:43","?","00:00:00","cat"]],"Titles":["UID","PID","PPID","C","STIME","TTY","TIME","CMD"]}
What you expected instead

The Engine API defines ps_args on GET /containers/{id}/top as the arguments passed to ps, with -ef as the default. With Docker, docker top top-a aux lists the columns of ps aux (USER, PID, %CPU, %MEM, VSZ, RSS, …), and -eo pid,rss,args lists PID, RSS and COMMAND.

If only the default can be supported, an error for other ps_args would at least make the difference visible.

Anything else

I hit this while reading a server's memory in an image without a shell or ps, where docker top CONTAINER -eo pid,rss,args is the way to get it without changing the container. Under Kiri the command succeeds but has no memory column.

Dominant language
Rust
Stars
7.5k
Forks
329
Avg merge
7h 48m
Merged PRs (30d)
105

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from libracoder/kiri

All issues in libracoder/kiri

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.