Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 2ed72a5

Browse files
Expose the machine readable state of a container when listing containers
Updated documentation to reflect the new State property in the inspect remote api Updated API changes for 1.23 Signed-off-by: Marius Gundersen <me@mariusgundersen.net>
1 parent 6f86bce commit 2ed72a5

3 files changed

Lines changed: 7 additions & 0 deletions

File tree

daemon/list.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ func (daemon *Daemon) transformContainer(container *container.Container, ctx *li
347347
newC.Command = container.Path
348348
}
349349
newC.Created = container.Created.Unix()
350+
newC.State = container.State.StateString()
350351
newC.Status = container.State.String()
351352
newC.HostConfig.NetworkMode = string(container.HostConfig.NetworkMode)
352353
// copy networks to avoid races

docs/reference/api/docker_remote_api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ This section lists each version from latest to oldest. Each listing includes a
9696

9797
[Docker Remote API v1.23](docker_remote_api_v1.23.md) documentation
9898

99+
* `GET /containers/json` returns the state of the container, one of `created`, `restarting`, `running`, `paused`, `exited` or `dead`.
100+
99101

100102
### v1.22 API changes
101103

docs/reference/api/docker_remote_api_v1.23.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ List containers
4949
"ImageID": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82",
5050
"Command": "echo 1",
5151
"Created": 1367854155,
52+
"State": "Exited",
5253
"Status": "Exit 0",
5354
"Ports": [{"PrivatePort": 2222, "PublicPort": 3333, "Type": "tcp"}],
5455
"Labels": {
@@ -81,6 +82,7 @@ List containers
8182
"ImageID": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82",
8283
"Command": "echo 222222",
8384
"Created": 1367854155,
85+
"State": "Exited",
8486
"Status": "Exit 0",
8587
"Ports": [],
8688
"Labels": {},
@@ -110,6 +112,7 @@ List containers
110112
"ImageID": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82",
111113
"Command": "echo 3333333333333333",
112114
"Created": 1367854154,
115+
"State": "Exited",
113116
"Status": "Exit 0",
114117
"Ports":[],
115118
"Labels": {},
@@ -139,6 +142,7 @@ List containers
139142
"ImageID": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82",
140143
"Command": "echo 444444444444444444444444444444444",
141144
"Created": 1367854152,
145+
"State": "Exited",
142146
"Status": "Exit 0",
143147
"Ports": [],
144148
"Labels": {},

0 commit comments

Comments
 (0)