question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Health property/method for Container object

See original GitHub issue

Is 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:

  1. Return None when it changes to healthy status before timeout
  2. Raise HealthCheckError exception when it changes to unhealthy status before timeout
  3. Raise HealthCheckTimeout exception when it reaches the timeout (still starting 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:closed
  • Created 5 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
maiamccormick-toastcommented, Apr 4, 2022

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.)

0reactions
roblevycommented, Nov 23, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found