The list of Docker statuses is here. However, when I list docker containers using the API, the statuses are shown in 'natural' sentences; e.g.:
Exited (0) NN seconds ago
Up NN days
- and so on...
I couldn't find the definitive list of all string outputs for all the statuses. In other words, I want to parse docker API status strings.
What are all the possible outputs of the Docker API for container statuses?
Here is the api Im talking about.
From their docs
In my experience, immediately on starting a container, it's
created
, thenrunning
, then when it exits with a zero or non-zero exit code, it isexited
.The logic by which the status summary is generated can be found in the Docker source code, in the file
container/states.go
, l. 41ff.. Basically, you'll get one of the following:In order to get a machine-readable output, I'd suggest using the
/containers/:id/json
endpoint, which will return a data structure like the following:I've not used the remote API, but I'm pretty sure what you actually want to do is get the ID of all containers, then get the
State
information for each container using/containers/(id)/json
:That way you get the same data in a much more standard form.