Skip to content

feat(ps): show container health status in STATUS column#4933

Merged
AkihiroSuda merged 1 commit into
containerd:mainfrom
haytok:ps-show-health-status
May 26, 2026
Merged

feat(ps): show container health status in STATUS column#4933
AkihiroSuda merged 1 commit into
containerd:mainfrom
haytok:ps-show-health-status

Conversation

@haytok
Copy link
Copy Markdown
Member

@haytok haytok commented May 23, 2026

docker ps displays the health check results for healthchecked containers in the STATUS column:

$ docker run -d --name health --health-cmd=true --health-interval=3s alpine sleep inf
ace14dd125355ac04e8cbad9f1cf2eaaa7209d76cb648ccefb81e45b986c58f7

$ docker ps
CONTAINER ID   IMAGE     COMMAND       CREATED          STATUS                    PORTS     NAMES
ace14dd12535   alpine    "sleep inf"   23 seconds ago   Up 22 seconds (healthy)             health

However, nerdctl ps doesn't show the health status.

Therefore, to ensure compatibility with Docker, this change makes nerdctl ps display the health check results in the STATUS column for containers that perform health checks.

After this change, the output looks like:

$ sudo nerdctl ps
CONTAINER ID    IMAGE                              COMMAND                   CREATED          STATUS                   PORTS    NAMES
02c64243528a    docker.io/library/alpine:latest    "sleep inf"               7 seconds ago    Up (health: starting)             hoge
$ sudo nerdctl ps
CONTAINER ID    IMAGE                              COMMAND                   CREATED         STATUS          PORTS    NAMES
690aa502978c    docker.io/library/alpine:latest    "sleep inf"               1 second ago    Up (healthy)             hoge
$ sudo nerdctl ps
CONTAINER ID    IMAGE                              COMMAND                   CREATED         STATUS            PORTS    NAMES
02c64243528a    docker.io/library/alpine:latest    "sleep inf"               2 hours ago     Up (unhealthy)             hoge

testCase := nerdtest.Setup()

testCase.Require = require.All(
require.Not(nerdtest.Docker),
Copy link
Copy Markdown
Member

@AkihiroSuda AkihiroSuda May 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the reason as a code comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I've added the reason. (// Docker CLI does not provide a standalone healthcheck command.)

`docker ps` displays the health check results for healthchecked containers
in the STATUS column:

```bash
$ docker run -d --name health --health-cmd=true --health-interval=3s alpine sleep inf
ace14dd125355ac04e8cbad9f1cf2eaaa7209d76cb648ccefb81e45b986c58f7

$ docker ps
CONTAINER ID   IMAGE     COMMAND       CREATED          STATUS                    PORTS     NAMES
ace14dd12535   alpine    "sleep inf"   23 seconds ago   Up 22 seconds (healthy)             health
```

However, `nerdctl ps` doesn't show the health status.

Therefore, to ensure compatibility with Docker, this change makes
`nerdctl ps` display the health check results in the STATUS column for
containers that perform health checks.

After this change, the output looks like:

```bash
$ sudo nerdctl ps
CONTAINER ID    IMAGE                              COMMAND                   CREATED          STATUS                   PORTS    NAMES
02c64243528a    docker.io/library/alpine:latest    "sleep inf"               7 seconds ago    Up (health: starting)             hoge
```

```bash
$ sudo nerdctl ps
CONTAINER ID    IMAGE                              COMMAND                   CREATED         STATUS          PORTS    NAMES
690aa502978c    docker.io/library/alpine:latest    "sleep inf"               1 second ago    Up (healthy)             hoge
```

```bash
$ sudo nerdctl ps
CONTAINER ID    IMAGE                              COMMAND                   CREATED         STATUS            PORTS    NAMES
02c64243528a    docker.io/library/alpine:latest    "sleep inf"               2 hours ago     Up (unhealthy)             hoge
```

Signed-off-by: Hayato Kiwata <dev@haytok.jp>
@haytok haytok force-pushed the ps-show-health-status branch from 2649a76 to da3187e Compare May 25, 2026 11:40
Copy link
Copy Markdown
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda AkihiroSuda merged commit 500f238 into containerd:main May 26, 2026
114 of 125 checks passed
@AkihiroSuda AkihiroSuda added this to the v2.3.2 milestone May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants