In order to ensure the health check of my container, I need to perform test calls to multiple URLS.
curl -f http://example.com
and curl -f http://example2.com
Is it possible to perform multiple curl calls for a docker health check?
In order to ensure the health check of my container, I need to perform test calls to multiple URLS.
curl -f http://example.com
and curl -f http://example2.com
Is it possible to perform multiple curl calls for a docker health check?
You can set a script as the healthcheck command that contains a more complex logic to perform the healthcheck. That way you can do multiple requests via curl and let the script only return positive if all requests succeeded.
# example dockerfile
COPY files/healthcheck.sh /healthcheck.sh
RUN chmod +x /healthcheck.sh
HEALTHCHECK --interval=60s --timeout=10s --start-period=10s \
CMD /healthcheck.sh
Although I cannot test, I think you can use the following
HEALTHCHECK CMD (curl --fail http://example.com && curl --fail http://example2.com) || exit 1
If you want first to check this command manually (without exit part), you can check the last error code by
echo $? -> in linux
and
echo %errorlevel% -> in windows
© 2022 - 2024 — McMap. All rights reserved.