Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Healthcheck fails in Docker with default .filebrowser.json: curl: (3) URL rejected: Bad hostname #3085

Closed
CorySanin opened this issue Apr 1, 2024 · 22 comments

Comments

@CorySanin
Copy link

CorySanin commented Apr 1, 2024

Description

This is a regression caused by #2938. Healthcheck fails due to .filebrowser.json having an empty address property. The healthcheck script used to default to localhost, now it defaults to empty string.

Expected behaviour

healthcheck script calls /health endpoint

What is happening instead?

curl fails, script exits with code 1

Additional context

I think this can be fixed by setting address to "localhost" in docker_config.json

How to reproduce?

docker run --rm -p 8080:80 filebrowser/filebrowser:v2.28.0

and wait for healthcheck

@smgsmagus
Copy link

same here:
fileb

@CorySanin
Copy link
Author

Ah, you're correct. The double quotes are introduced by executing jq without the -r (--raw-output) flag. I didn't realize there was already logic in healthcheck.sh intended to fallback to "localhost".

Not sure why yours wasn't falling back to localhost though. Adding the -r flag is all I needed.

CorySanin added a commit to CorySanin/filebrowser that referenced this issue Apr 1, 2024
@Zulux91
Copy link

Zulux91 commented Apr 1, 2024

Ah, you're correct. The double quotes are introduced by executing jq without the -r (--raw-output) flag. I didn't realize there was already logic in healthcheck.sh intended to fallback to "localhost".

Not sure why yours wasn't falling back to localhost though. Adding the -r flag is all I needed.

Oh yes, you're right. Only -r is needed. Just tested on a fresh container and it works fine.

@Tuumke
Copy link

Tuumke commented Apr 2, 2024

I don't understand what the fix is here. I have a default filebrowser installation and keeps giving me this healtcheck error too:

curl: (3) URL rejected: Bad hostname

@Zulux91
Copy link

Zulux91 commented Apr 2, 2024

I don't understand what the fix is here. I have a default filebrowser installation and keeps giving me this healtcheck error too:

curl: (3) URL rejected: Bad hostname

Were you able to inspect the pull request? That might make it clear. There's a healthcheck.sh script inside the container that needs to be changed to incorporate the mentioned -r parameter.

@Guiorgy
Copy link

Guiorgy commented Apr 2, 2024

I don't understand what the fix is here. I have a default filebrowser installation and keeps giving me this healtcheck error too:

curl: (3) URL rejected: Bad hostname

  1. Execute an interactive shell inside the container
    docker exec -it -u root [CONTAINER_NAME] ash
  2. Install nano (or another editor of your choice):
    apk add --no-cache nano
  3. Edit healthcheck.sh:
    nano healthcheck.sh
  4. Add the -r or --raw-output flag to the jq command:
    Change ADDRESS=${FB_ADDRESS:-$(jq .address /.filebrowser.json)} to ADDRESS=${FB_ADDRESS:-$(jq -r .address /.filebrowser.json)}

@Tuumke
Copy link

Tuumke commented Apr 2, 2024

I don't understand what the fix is here. I have a default filebrowser installation and keeps giving me this healtcheck error too:
curl: (3) URL rejected: Bad hostname

1. Execute an interactive shell inside the container
   ```shell
   docker exec -it [CONTAINER_NAME] ash
   ```

2. Install nano (or another editor of your choice):
   ```shell
   apk add --no-cache nano
   ```

3. Edit `healthcheck.sh`:
   ```shell
   nano healthcheck.sh
   ```

4. Add the `-r` or `--raw-output` flag to the jq command:
   Change `ADDRESS=${FB_ADDRESS:-$(jq .address /.filebrowser.json)}` to `ADDRESS=${FB_ADDRESS:-$(jq -r .address /.filebrowser.json)}`

Guess this wont work for me, as it repulls the image in portainer when i change my compose to run as root (otherwise i cant edit healtcheck). I need a new docker image build :-(

@Guiorgy
Copy link

Guiorgy commented Apr 2, 2024

@Tuumke You don't have to run the container as root. If you are using Portainer, you can execute a shell from the webui (select /bin/ash), and there you can specify the user, type root inside:

image
image

PS. Fixed my comment above

@Zulux91
Copy link

Zulux91 commented Apr 2, 2024

Guess this wont work for me, as it repulls the image in portainer when i change my compose to run as root (otherwise i cant edit healtcheck). I need a new docker image build :-(

I fixed mine by doing a cat to the healthcheck (docker exec -it filebrowser cat healthcheck.sh) to get its content. Made a copy outside of the container since you have the /srv mounted to some place inside the machine, keeping the same name. Edited the script to add the -r flag and copied back the edited file, replacing the old one.

Here's a one line command as a temp fix:

docker exec -it [CONTAINER_NAME] sed -i 's/\(jq .address \/.filebrowser\.json\)/\1 -r/' healthcheck.sh

@mapxn
Copy link

mapxn commented Apr 2, 2024

Have the same issue.

image

@Guiorgy
Copy link

Guiorgy commented Apr 2, 2024

@mapxn and future readers, the problem has been identidied and fixed (see #3087), no need to spam report. Either wait for the next release, or use one of the optiones above to temporarily fix it yourself.

@seppeel
Copy link

seppeel commented Apr 6, 2024

Guess this wont work for me, as it repulls the image in portainer when i change my compose to run as root (otherwise i cant edit healtcheck). I need a new docker image build :-(

I fixed mine by doing a cat to the healthcheck (docker exec -it filebrowser cat healthcheck.sh) to get its content. Made a copy outside of the container since you have the /srv mounted to some place inside the machine, keeping the same name. Edited the script to add the -r flag and copied back the edited file, replacing the old one.

Here's a one line command as a temp fix:

docker exec -it [CONTAINER_NAME] sed -i 's/\(jq .address \/.filebrowser\.json\)/\1 -r/' healthcheck.sh

Thanks for your workaround!

If your container does not run as root, just add "-u root".

docker exec -it -u root [CONTAINER_NAME] sed -i 's/\(jq .address \/.filebrowser\.json\)/\1 -r/' healthcheck.sh

@lustrant
Copy link

healthechk.sh shoudl be changed to:

#!/bin/sh PORT=${FB_PORT:-$(jq -r .port /.filebrowser.json)} ADDRESS=${FB_ADDRESS:-$(jq -r .address /.filebrowser.json)} ADDRESS=${ADDRESS:-localhost} curl -f http://$ADDRESS:$PORT/health || exit 1

-r needs to be added in order to give just the strings and not "strings", i.e. the address is
http://filebrowser:431/health
and not
http://"filebrowser":431/health

@Guiorgy
Copy link

Guiorgy commented Apr 12, 2024

@lustrant Already has been (see #3087)

@Tuumke
Copy link

Tuumke commented Apr 12, 2024

But when can we see this fixed in the docker image? :O
Been a while now, surely this is pushed easy into a new image?

@CorySanin
Copy link
Author

Needs to get merged first.

@jinks
Copy link

jinks commented Apr 13, 2024

If fixing a typo that makes the default docker image unusable takes more than two weeks, that doesn't really instill confidence in the project.

@Guiorgy
Copy link

Guiorgy commented Apr 13, 2024

@jinks If you think you can do better, why don't you fork this project and maintain it better instead. Don't forget that this project is maintained by unpaid volunteers with their own lives, and no obligations to any of us.

@jinks
Copy link

jinks commented Apr 13, 2024

@Guiorgy Because I don't care enough to maintain a project long-term.

The question remains, why pushing a 2-letter fix to Docker Hub remains such a chore. It's not even part of the core code. Unless there is something seriously wrong with the release process, I would imagine pushing the fix to Docker should be less work than this thread has already consumed.

@Guiorgy
Copy link

Guiorgy commented Apr 13, 2024

@jinks As I said, they have their lives, maybe they have something more urgent going on. And it's not like the container is completely broken, or hard to manually workaround.

@ying001ch
Copy link

I'm running into this issue as well, and my workaround is to add an environment variable FB_ADDRESS: 0.0.0.0 so that the command jq .address /.filebrowser.json doesn't work

@Guiorgy
Copy link

Guiorgy commented Apr 24, 2024

FYI, the fix has been merged (#3130), so just wait for the next release 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants