Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement docker healthchecks #149

Conversation

EdwinHoksberg
Copy link

Implement a healthcheck for all docker images. The healthcheck will execute a PING command to the redis server every 30 seconds. When this command fails by either a timeout of 5 seconds or unexpected output, the healthcheck will fail and trigger an event which a user can capture.

One thing I'm not sure about is the numbers I used, specifically for the interval(30s) and the timeout (5s). These can be changed if necessary.

Output in docker ps(see the status column):

# First 30 seconds when a container was started
CONTAINER ID        IMAGE                              COMMAND                  CREATED             STATUS                            PORTS                                              NAMES
455a1e6bf0c1        test/redis:latest                  "docker-entrypoint.s…"   2 minutes ago       Up 6 seconds (health: starting)   6379/tcp, 0.0.0.0:6379->63799/tcp                  test-redis

# After 30 seconds when the first healthcheck was executed
CONTAINER ID        IMAGE                              COMMAND                  CREATED             STATUS                    PORTS                                              NAMES
455a1e6bf0c1        test/redis:latest                  "docker-entrypoint.s…"   2 minutes ago       Up 42 seconds (healthy)   6379/tcp, 0.0.0.0:6379->63799/tcp                  test-redis

Full reference here: https://docs.docker.com/engine/reference/builder/#healthcheck
Fixes #91

@wglambert
Copy link

wglambert commented Jul 9, 2018

See docker-library/cassandra#76 (comment)

I do not feel that generalized healthchecks on the official images are really that useful . . .

The healthcheck repo serves as an example for creating your own image derived from the healthcheck-prototypes provided.

There is an example set of prototype images (available under https://hub.docker.com/u/healthcheck) for enabling HEALTHCHECK behavior in the official images.
These images are not maintained and are only provided as a reference in implementing your own HEALTHCHECK.

So if users want added functionality: healthcheck or otherwise then we try to demonstrate best practices such that users would have a reference for maintaining their own images for the specific functionality they want; as we try to maintain as close to upstream as possible to provide that base platform to build off of.

@EdwinHoksberg
Copy link
Author

The healthcheck repo serves as an example for creating your own image derived from the healthcheck-prototypes provided.

Ah, I didn't even know that existed, I guess I'll close this then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants