Closed joubertredrat closed 1 year ago
https://github.com/renatomefi/php-fpm-healthcheck looks promising for the fpm variant (I'm not asking @joubertredrat to implement it, just discussing in one central place).
This looks good to me, any other input from the development team?
@williamdes I agree with you, you can use curl
as health check too, but, the problem with curl
and the reason that I don't like to use curl
is that nc
check for open and listening port, curl
does a request and depending on the web server running, you can pollute the logs, as example below, that I'm using curl
as health check. Using nc
you don't have this problem.
matomo-protecttrackid-devbox-matomo1-1 | [Wed Feb 8 15:26:49 2023] 127.0.0.1:36145 Closing
matomo-protecttrackid-devbox-matomo1-1 | [Wed Feb 8 15:26:52 2023] 127.0.0.1:44445 Accepted
matomo-protecttrackid-devbox-pma-1 | 127.0.0.1 - - [08/Feb/2023:15:26:49 +0000] "GET / HTTP/1.1" 200 140777 "-" "curl/7.74.0"
matomo-protecttrackid-devbox-pma-1 | 127.0.0.1 - - [08/Feb/2023:15:26:53 +0000] "GET / HTTP/1.1" 200 140777 "-" "curl/7.74.0"
matomo-protecttrackid-devbox-pma-1 | 127.0.0.1 - - [08/Feb/2023:15:26:56 +0000] "GET / HTTP/1.1" 200 140777 "-" "curl/7.74.0"
matomo-protecttrackid-devbox-pma-1 | 127.0.0.1 - - [08/Feb/2023:15:26:59 +0000] "GET / HTTP/1.1" 200 140777 "-" "curl/7.74.0"
matomo-protecttrackid-devbox-pma-1 | 127.0.0.1 - - [08/Feb/2023:15:27:02 +0000] "GET / HTTP/1.1" 200 140777 "-" "curl/7.74.0"
matomo-protecttrackid-devbox-matomo1-1 | [Wed Feb 8 15:26:52 2023] 127.0.0.1:44445 Closed without sending a request; it was probably just an unused speculative preconnection
matomo-protecttrackid-devbox-matomo1-1 | [Wed Feb 8 15:26:52 2023] 127.0.0.1:44445 Closing
matomo-protecttrackid-devbox-pma-1 | 127.0.0.1 - - [08/Feb/2023:15:27:05 +0000] "GET / HTTP/1.1" 200 140777 "-" "curl/7.74.0"
matomo-protecttrackid-devbox-pma-1 | 127.0.0.1 - - [08/Feb/2023:15:27:09 +0000] "GET / HTTP/1.1" 200 140777 "-" "curl/7.74.0"
matomo-protecttrackid-devbox-pma-1 | 127.0.0.1 - - [08/Feb/2023:15:27:12 +0000] "GET / HTTP/1.1" 200 140777 "-" "curl/7.74.0"
matomo-protecttrackid-devbox-pma-1 | 127.0.0.1 - - [08/Feb/2023:15:27:15 +0000] "GET / HTTP/1.1" 200 140777 "-" "curl/7.74.0"
matomo-protecttrackid-devbox-pma-1 | 127.0.0.1 - - [08/Feb/2023:15:27:18 +0000] "GET / HTTP/1.1" 200 140777 "-" "curl/7.74.0"
matomo-protecttrackid-devbox-matomo1-1 | [Wed Feb 8 15:26:55 2023] 127.0.0.1:41011 Accepted
matomo-protecttrackid-devbox-matomo1-1 | [Wed Feb 8 15:26:55 2023] 127.0.0.1:41011 Closed without sending a request; it was probably just an unused speculative preconnection
matomo-protecttrackid-devbox-pma-1 | 127.0.0.1 - - [08/Feb/2023:15:27:22 +0000] "GET / HTTP/1.1" 200 140777 "-" "curl/7.74.0"
matomo-protecttrackid-devbox-pma-1 | 127.0.0.1 - - [08/Feb/2023:15:27:25 +0000] "GET / HTTP/1.1" 200 140777 "-" "curl/7.74.0"
matomo-protecttrackid-devbox-matomo1-1 | [Wed Feb 8 15:26:55 2023] 127.0.0.1:41011 Closing
matomo-protecttrackid-devbox-matomo1-1 | [Wed Feb 8 15:26:58 2023] 127.0.0.1:41765 Accepted
matomo-protecttrackid-devbox-pma-1 | 127.0.0.1 - - [08/Feb/2023:15:27:28 +0000] "GET / HTTP/1.1" 200 140777 "-" "curl/7.74.0"
matomo-protecttrackid-devbox-pma-1 | 127.0.0.1 - - [08/Feb/2023:15:27:32 +0000] "GET / HTTP/1.1" 200 140777 "-" "curl/7.74.0"
While your reasoning for wanting to use netcat over curl makes sense and I know many people like to have healthchecks available, the policy of the official Docker library group to not want healthchecks means we are unlikely to directly implement this.
However, I'd be open to the idea of posting or maintaining documentation about how to implement it as a derivative of the official Docker images, perhaps a Wiki page with a Dockerfile or something, it seems adding another layer like that wouldn't be too difficult, but I'd have to test that a bit.
Okay guys, thanks
@williamdes I agree with you, you can use curl as health check too, but, the problem with curl and the reason that I don't like to use curl is that nc check for open and listening port, curl does a request and depending on the web server running, you can pollute the logs, as example below, that I'm using curl as health check. Using nc you don't have this problem.
I agree too, it creates a lot of logs and we should probably provide a ping endpoint or silence some files from the logs.
This PR adds netcat to have options to do health check on running container.
Example on terminal
Example on docker compose using
docker-compose.yml
from this project as base: