You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ docker container ls --filter name=example_example_1
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6e9eef9909f7 example:latest "nginx -g 'daemon ..." 5 hours ago Up 5 hours (healthy) 80/tcp, 443/tcp, 0.0.0.0:8080->8080/tcp example_example_1
But, the Docker Compose CLI does not
$ docker-compose ps example
Name Command State Ports
------------------------------------------------------------------------------------------------
example_example_1 nginx -g daemon off; Up 443/tcp, 80/tcp, 0.0.0.0:8080->8080/tcp
It might be nice to display the same health status, especially for those of us using Compose 2.1 and the depends_on / condition / service_healthy feature.
It looks like this method, human_readable_state, would need to be enhanced to display health status if this service has a HEALTHCHECK defined. As stated at the beginning of the class, the dictionary of internal state is coming from the Docker engine API (Inspect a container).
GET /containers/{id}/json
But, I'm not quite sure that API endpoint returns the current health status. I don't see any "health" properties, even on the State (although, maybe the example is incomplete).
Perhaps, we can use the same call as the service_healthy feature, to get the container's health status directly from inspect and construct the new status string?
I think adding just the health status is OK for now. I don't know if it's Compose's intent to mirror the entire status string.
Note that the Docker CLI shows a bit of a custom message if the healthcheck is still inside of the "starting" period. The health status is technically just starting, but it prints health: starting.
STATUS
Up Less than a second (health: starting)
Afterwards, it just shows the raw health status (like healthy).
I created a Pull Request for this change. Decided to go with similar behavior as @AnthonyMastrean mentioned above regarding the health: starting. Did not add the Up for .....
Activity
AnthonyMastrean commentedon Jan 8, 2018
It looks like this method,
human_readable_state, would need to be enhanced to display health status if this service has a HEALTHCHECK defined. As stated at the beginning of the class, the dictionary of internal state is coming from the Docker engine API (Inspect a container).But, I'm not quite sure that API endpoint returns the current health status. I don't see any "health" properties, even on the
State(although, maybe the example is incomplete).Perhaps, we can use the same call as the
service_healthyfeature, to get the container's health status directly frominspectand construct the new status string?bosorawis commentedon Jan 29, 2018
@AnthonyMastrean Looks like
inspectAPI endpoint does return Health status if "healthcheck" is specified for the container.I could try adding
healthproperty for container object and construct new status string from there.bosorawis commentedon Jan 29, 2018
Should I also add
timeportion of the status string as well? LikeUp for ......... (health), or justUp (health)is fine?AnthonyMastrean commentedon Jan 29, 2018
I think adding just the health status is OK for now. I don't know if it's Compose's intent to mirror the entire status string.
Note that the Docker CLI shows a bit of a custom message if the healthcheck is still inside of the "starting" period. The health status is technically just
starting, but it printshealth: starting.Afterwards, it just shows the raw health status (like
healthy).You might replicate this behavior, at least.
bosorawis commentedon Feb 3, 2018
I created a Pull Request for this change. Decided to go with similar behavior as @AnthonyMastrean mentioned above regarding the
health: starting. Did not add theUp for .....