Skip to content

Commit

Permalink
Add HEALTHCHECK instruction to Dockerfile.
Browse files Browse the repository at this point in the history
The `Dockerfile` currently does not have a `HEALTHCHECK` instruction. Users of the Docker image currently need to add it manually (e.g. via Docker Compose). Instead, the `Dockerfile` itself should include the instruction.

To determine whether the service is healthy, one can use the [`PING`](https://redis.io/docs/latest/commands/ping/) command via the [Redis CLI](https://redis.io/docs/latest/develop/connect/cli/), which is already part of the image. The command “is useful for […] verifying the server's ability to serve data”.

Most of the default `HEALTHCHECK` [options](https://docs.docker.com/reference/dockerfile/#healthcheck) seem reasonable:
```
--interval=30s
--timeout=30s
--start-interval=5s
--retries=3
```

I set `--start-period=1s` because the default of `0s` is too quick for this program.

Users of the image can still override the `HEALTHCHECK` instruction if they want to customize the command or the options.
  • Loading branch information
fumoboy007 committed Aug 26, 2024
1 parent a8b4897 commit c5d466c
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 0 deletions.
4 changes: 4 additions & 0 deletions 6.2/alpine/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions 6.2/debian/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions 7.0/alpine/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions 7.0/debian/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions 7.2/alpine/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions 7.2/debian/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions 7.4-rc/alpine/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions 7.4-rc/debian/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions 7.4/alpine/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions 7.4/debian/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Dockerfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,7 @@ ENTRYPOINT ["docker-entrypoint.sh"]

EXPOSE 6379
CMD ["redis-server"]

# Search for "PONG" instead of relying on the exit status because of
# https://stackoverflow.com/a/71504657/815742.
HEALTHCHECK --start-period=1s CMD redis-cli ping | grep ^PONG$

0 comments on commit c5d466c

Please sign in to comment.