There's already a similar question at What happens to a Docker Container when HEALTHCHECK fails, but the secondary point about || exit 1
was not the main focus of the question (and it hasn't been answered directly).
The Dockerfile reference contains the following example:
HEALTHCHECK
--interval=5m --timeout=3s \
CMD curl -f http://localhost/ || exit 1
I have seen several other examples of healthcheck instructions ending in || exit 1
around the Internet. Even when the only two possible exit codes of the original command are 0 and 1.
What's the point of || exit 1
?
Wont curl -f
exit on its own with error code 22? Does Docker fail to recognise error codes other than 1?