Version not set in Docker container? #42

Open
opened 2026-01-19 18:28:43 +00:00 by michael · 6 comments
Owner

Originally created by @luckman212 on GitHub.

Hi, and 🙏 thank you for transfer.sh !

I am running it in Docker, and wanted to make a simple update notifier when new releases are tagged. So I wanted a way to return the current running version from a script.

Looking at the source, it seems that there is a version cli argument that should output the running version

29d93c6da0/cmd/cmd.go (L317)

but when I tried it, it's empty:

# docker pull dutchcoders/transfer.sh:latest
latest: Pulling from dutchcoders/transfer.sh
Digest: sha256:ebeded1b0ba4e23fb41b58c762b5e885559d625aa5ea48f70a9adc3170ed8c17
Status: Image is up to date for dutchcoders/transfer.sh:latest
docker.io/dutchcoders/transfer.sh:latest

# docker exec -it transfersh /go/bin/transfersh version
transfer.sh : Easy file sharing from the command line

Am I doing something wrong? Is there another way to retrieve the current version?

Originally created by @luckman212 on GitHub. Hi, and 🙏 thank you for transfer.sh ! I am running it in Docker, and wanted to make a simple update notifier when new releases are tagged. So I wanted a way to return the current running version from a script. Looking at the source, it seems that there is a `version` cli argument that should output the running version https://github.com/dutchcoders/transfer.sh/blob/29d93c6da065f6fdf73654c682ae3cc656c70e6b/cmd/cmd.go#L317 but when I tried it, it's empty: ``` # docker pull dutchcoders/transfer.sh:latest latest: Pulling from dutchcoders/transfer.sh Digest: sha256:ebeded1b0ba4e23fb41b58c762b5e885559d625aa5ea48f70a9adc3170ed8c17 Status: Image is up to date for dutchcoders/transfer.sh:latest docker.io/dutchcoders/transfer.sh:latest # docker exec -it transfersh /go/bin/transfersh version transfer.sh : Easy file sharing from the command line ``` Am I doing something wrong? Is there another way to retrieve the current version?
Author
Owner

@luckman212 commented on GitHub:

Is there any workaround you could suggest? What about just hardcoding the current version in a VERSION file and having the Dockerfile read from that?

@luckman212 commented on GitHub: Is there any workaround you could suggest? What about just hardcoding the current version in a `VERSION` file and having the Dockerfile read from that?
Author
Owner

@paolafrancesca commented on GitHub:

hello @luckman212 , thanks for reporting this bug

the problem is that the build command on docker file does not work properly, with git describe --tags failing since it's run not inside a git repo

@paolafrancesca commented on GitHub: hello @luckman212 , thanks for reporting this bug the problem is that the [build command](https://github.com/dutchcoders/transfer.sh/blob/main/Dockerfile#L17) on docker file does not work properly, with `git describe --tags` failing since it's run not inside a git repo
Author
Owner

@amayer5125 commented on GitHub:

I believe the issue is that ".git" is in .dockerignore. When COPY . . is run, the files in .dockerignore are skipped. Since the .git directory isn't copied into the docker image the command that sets the version (git describe --tags) fails. Removing ".git" from .dockerignore fixes the issue for me.

$ docker run --rm transfer.sh version 
transfer.sh v1.6.1-1-gd4f1b84: Easy file sharing from the command line

I don't believe removing .git from the .dockerignore file is the correct solution for the repo though because then the container will be larger.

@amayer5125 commented on GitHub: I believe the issue is that ".git" is in .dockerignore. When `COPY . .` is run, the files in .dockerignore are skipped. Since the .git directory isn't copied into the docker image the command that sets the version (`git describe --tags`) fails. Removing ".git" from .dockerignore fixes the issue for me. ``` $ docker run --rm transfer.sh version transfer.sh v1.6.1-1-gd4f1b84: Easy file sharing from the command line ``` I don't believe removing .git from the .dockerignore file is the correct solution for the repo though because then the container will be larger.
Author
Owner

@luckman212 commented on GitHub:

Ok I'll look into that, thanks

@luckman212 commented on GitHub: Ok I'll look into that, thanks
Author
Owner

@stefanbenten commented on GitHub:

You can use watchtower to achieve the same without having to write a script :)

@stefanbenten commented on GitHub: You can use watchtower to achieve the same without having to write a script :)
Author
Owner

@paolafrancesca commented on GitHub:

I don't believe removing .git from the .dockerignore file is the correct solution for the repo though because then the container will be larger.

the final image is based on scratch, we can remove .git from the .dockerignore without having a bigger image. the .git folder will be copied only in the build stage of the image

@paolafrancesca commented on GitHub: > I don't believe removing .git from the .dockerignore file is the correct solution for the repo though because then the container will be larger. the final image is based on scratch, we can remove .git from the .dockerignore without having a bigger image. the .git folder will be copied only in the build stage of the image
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dutchcoders/transfer.sh#42