Skip to content

Commit 5629ba8

Browse files
Merge pull request #26149 from azdle/docker-api-container-status
compat: fix ContainerState.Status JSON values
2 parents 9800f64 + c39fd06 commit 5629ba8

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ It’s important to describe the change in plain English for the reviewer to ver
236236
Solve only one problem per patch.
237237
If your description starts to get long, that’s a sign that you probably need to split up your patch.
238238

239-
If the patch fixes a logged bug entry, refer to that bug entry by number and URL.
239+
If the patch fixes a logged bug entry, refer to that bug entry by number or URL.
240240
If the patch follows from a mailing list discussion, give a URL to the mailing list archive.
241241
Please format these lines as `Fixes:` followed by the URL or, for Github bugs, the bug number preceded by a #.
242242
For example:

pkg/api/handlers/compat/containers.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,20 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*container.InspectResp
463463
state.Running = true
464464
}
465465

466-
// Dockers created state is our configured state
467-
if state.Status == define.ContainerStateCreated.String() {
468-
state.Status = define.ContainerStateConfigured.String()
466+
// map our statuses to Docker's statuses
467+
switch state.Status {
468+
case define.ContainerStateConfigured.String(), define.ContainerStateCreated.String():
469+
state.Status = "created"
470+
case define.ContainerStateRunning.String(), define.ContainerStateStopping.String():
471+
state.Status = "running"
472+
case define.ContainerStatePaused.String():
473+
state.Status = "paused"
474+
case define.ContainerStateRemoving.String():
475+
state.Status = "removing"
476+
case define.ContainerStateStopped.String(), define.ContainerStateExited.String():
477+
state.Status = "exited"
478+
default:
479+
state.Status = "" // unknown state
469480
}
470481

471482
if l.HasHealthCheck() && state.Status != "created" {

test/apiv2/20-containers.at

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ t GET containers/status-test/json 200 .State.Status="running"
698698

699699
podman stop status-test &
700700
sleep 1
701-
t GET containers/status-test/json 200 .State.Status="stopping"
701+
t GET containers/status-test/json 200 .State.Status="running"
702702

703703
sleep 3
704704
t GET containers/status-test/json 200 .State.Status="exited"

0 commit comments

Comments
 (0)