make `PORTS` in `nerdctl ps` or `nerdctl compose ps` easier to view.
What is the problem you're trying to solve
In the latest version, when we start a container specifying multiple port mappings with -p, the following is displayed.
> sudo nerdctl run -d --name nginx -p 22200-22210:22200-22210 nginx
fbe04ad60307165ccfd84aaec5ea1afa6f54bcdcf8200a941ce195a539e8a7ea
> sudo nerdctl ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fbe04ad60307 docker.io/library/nginx:latest "/docker-entrypoint.…" 4 seconds ago Up 0.0.0.0:22200->22200/tcp, 0.0.0.0:22201->22201/tcp, 0.0.0.0:22202->22202/tcp, 0.0.0.0:22203->22203/tcp, 0.0.0.0:22204->22204/tcp, 0.0.0.0:22205->22205/tcp, 0.0.0.0:22206->22206/tcp, 0.0.0.0:22207->22207/tcp, 0.0.0.0:22208->22208/tcp, 0.0.0.0:22209->22209/tcp, 0.0.0.0:22210->22210/tcp nginx
On the other hand, in Docker, consecutive port mappings are displayed in an easy-to-read manner.
> docker run -d --name nginx -p 22200-22210:22200-22210 nginx
eaf0d0738d61e12bcd8306f2df14937fa752c4a99f60a1c7093e2f5c6bee6b26
> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
eaf0d0738d61 nginx "/docker-entrypoint.…" 1 second ago Up Less than a second 80/tcp, 0.0.0.0:22200-22210->22200-22210/tcp, :::22200-22210->22200-22210/tcp nginx
Therefore, in this issue, we'll make PORTS in nerdctl ps or nerdctl compose ps easier to view.
Describe the solution you'd like
Fix FormatPorts()
https://github.com/containerd/nerdctl/blob/b60fbeaad1fb4c43ab29ea4751d78d6a4a735686/pkg/formatter/formatter.go#L115-L128
Additional context
related discussions
- https://github.com/containerd/nerdctl/pull/4290#issuecomment-2990447041
HI, maintainers!
I'll work on this issue, so could you assign this to me?
The tag enhancement might be better than kind/feature.
Hi! Me, @ShivanshNikhra, and @aravsrid are a group of three students working on open-source issues for our virtualization course. We’re interested in taking on this issue and coordinating the work among ourselves to submit a single PR.
We estimate we can complete it within the next month. Would it be okay if we proceed with this issue? If you prefer assignments, we’re happy to be assigned as well. Thanks!
@haytok Are you still planning to work on this?
@AkihiroSuda I have a draft PR, so I'll create it right away!