Health property/method for Container object
See original GitHub issueIs it possible to provide some properties or methods related to HEALTHCHECK in Container object? This is convenient to know the HEALTHCHECK result by using much simpler way rather than just calling Low-level API inspect_container
.
I found someone had proposed before https://github.com/docker/docker-py/pull/1726 but it’s long time ago, so is there any plan?
And I think it is great if there is a method Container.raise_for_health(timeout)
that can check container itself whether it is healthy or not until timeout. The spec may like below:
- Return
None
when it changes tohealthy
status before timeout - Raise
HealthCheckError
exception when it changes tounhealthy
status before timeout - Raise
HealthCheckTimeout
exception when it reaches the timeout (stillstarting
status)
Then, the client usage will like,
client = docker.from_env()
container = client.containers.run('nginx', healthcheck={'test': 'curl localhost'})
container.raise_for_health(timeout=60)
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Container class | Microsoft Learn
Properties ; id ; items. Operations for creating new items, and reading/querying all items For reading, replacing, or deleting an existing item, use...
Read more >Running InterSystems IRIS for Health in a Docker Container
From the Home page, select Health. In the top navigation bar, select Installer Wizard. Select Configure Network Host Name and enter the new...
Read more >Implement Health Checks for Kubernetes in Your Application
This method registers the health checks service in the DI container and returns a IHealthChecksBuilder instance which can be used to ...
Read more >Containers — Docker SDK for Python 6.0.1 documentation
Specify a test to perform to check that the container is healthy. ... Each item in the list is expected to be a...
Read more >Container Property - Raster, Medical, Document Help
Syntax. C#. VB. Objective-C C++ · Remarks. Every AnnAutomation has one AnnContainer object. · Example. For an example, refer to AnnAutomationManager.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I get the reasoning for not supporting health check result as a
container
property, but in case another datapoint is useful, this functionality would make a LOT of sense for my current project. (We got it working with @roblevy’s hack linked above, but it’s weird from a readability/code ergonomics perspective to have a separate docker API client for something you expect to be supported by the SDK.)FYI, I’ve hacked together a response to this SO question before I knew that you’d already rejected the idea of waiting on a health check.
For things like database engines, waiting on a health check is vital because the container will be “Started” long before the database is up and running.