docker / docker/cli

Add a new template for formatting

Open
#3,371 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
6.1k
Forks
2.2k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

I am using swarm to run the services/containers. So some text is prepended and appended to the actual container name.
of this sort stackname_containername.1.pmybkzo8ovlirri0rf1syyo4p
When I do a docker stats with --format option

docker stats --no-stream --format '{{.Name}}\t:\t{{.CPUPerc}}'

It prints -

<stackname>_<container-name>.1.<some-gibberish> 0.3% ...

I want to trim the gibberish on basis of regex. These are the valid templates provided -
https://github.com/docker/cli/blob/a32cd16160f1b41c1c4ae7bee4dac929d1484e59/templates/templates.go

so I tried to use split, and was able to remove the first for 'most' containers which were same. I can't try truncate as each container names differs and I can't calculate the length. I tried pipe and then split again but since the split returned []string, it didn't work.

Is there a way to get my outcome. Should I send a PR with a new template/formatter for such usecase? Is it even a valid usecase for people?

Contributor guide

Open the contributing guide

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.

Research direction

Start with templates/templates.go and the existing docker stats --format templates. Determine whether the requested regex-based name transformation fits the current template or formatter behavior; the issue does not identify a target implementation file, test, or concrete completion criterion.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.