Container fails healthcheck when custom_user and password enabled
micahmorgan1 opened this issue · 3 comments
Describe the bug
Using Portainer I was able to get the image up and running. The env options seem to work, but when I enable the custom_user and custom password options the container fails the healthcheck and gets a warning label "unhealthy" If I turn those options off, healthcheck passes.
The error log shows a 401 unauthorized error, returning an exit code 1.
I'm assuming this is because the pop-up user log-in is preventing the curl script from accessing the page and getting the response it needs to issue the exit code 0.
The container seems to run fine, but I was hoping to get rid of the this warning label. Perhaps it's a portainer issue. Any help or direction would be appreciated.
I'll have to look. The container runs in my local network so I have not changed it from the default.
I'll try to reproduce next week.
You can include the authentication information in your curl command using the -u option. For example:
HEALTHCHECK CMD curl --fail --user ${username}:${password} http://localhost:8080/ || exit 1
But i don't know how it would act if no auth is set...
I just tried this project, it works perfectly. But I exeperinced this problem too. Fixed adding this to my compose.yml
:
healthcheck:
test: ["CMD", "curl", "--fail", "--user", "${CUSTOM_USER}:${PASSWORD}", "http://localhost:8080/"]
interval: 1m30s
timeout: 10s
retries: 3
start_period: 30s
I tested it a little bit and works both in case you specify CUSTOM_USER
and PASSWORD
or not. Anyway I'll fork the project and suggest to modify the HEALTHCHECK directive in the Dockerfile
in order to take into account these 2 env vars, without the need to ovverride the check in the compose