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

Provide a docker image for running this command without installation #331

Closed
hsudbrock opened this issue Oct 5, 2018 · 13 comments
Closed
Labels
packaging/tooling question Further information is requested

Comments

@hsudbrock
Copy link

I find it quite useful on the console to run commands such as bat using docker - so that I don't need to install anything, and just have to pull the docker image when running the command for the first time.

I could not find a docker image for bat - is there maybe already one that I missed? (If there is none, I could configure one and contribute the dockerfile to this repo, if wanted.)

@sharkdp
Copy link
Owner

sharkdp commented Oct 5, 2018

I understand that Docker images are provided for complicated programs like web servers, databases etc., but bat is really just a single binary executable. Wouldn't a Docker image be a little bit of overkill? 😄

@sharkdp sharkdp added question Further information is requested packaging/tooling labels Oct 5, 2018
@hsudbrock
Copy link
Author

While docker images are really helpful for complicated programs, I believe that they have also benefits for small programs. To list some:

  • One can quite easily control the access rights of the program (for a tool like bat, I would, e.g., run it in a container into which I mount the current folder read-only - to be sure that my files are never modified).
  • One can easily "install" the program by doing a docker pull even if the standard package management does not provide a package (consider, e.g., Ubuntu for bat, where one needs to download the binary first, and cannot install directly via apt (yet)).
  • Uninstallation is really easy - just delete the docker image, and everything is gone. (E.g., no need to remember to remove both the downloaded Debian package and the binary when uninstalling bat.)

This is somewhat in the spirit of Jessie Frazelle's 'docker containers on the desktop' (see https://blog.jessfraz.com/post/docker-containers-on-the-desktop/ or https://github.com/jessfraz/dockerfiles) - which I consider quite useful. So when I stumbled upon bat recommended by a colleague, I first looked for a docker file :)

Not sure if this convinces you, let's see. I will build a docker image for myself anyway, if you like what I wrote above I can contribute the corresponding Dockerfile here.

@sharkdp
Copy link
Owner

sharkdp commented Oct 5, 2018

Interesting, thank you for the explanation and the references.

Do you have any experience on what the runtime overhead would be? bat's startup is actually quite slow (approximately 45 ms for me), but that is still fast enough to hardly be noticed.

I will build a docker image for myself anyway, if you like what I wrote above I can contribute the corresponding Dockerfile here.

That would be great, thanks!

@sharkdp
Copy link
Owner

sharkdp commented Oct 5, 2018

This could be a starting point:

Dockerfile:

FROM rust:1.29.1

WORKDIR /usr/src/bat
COPY . .

RUN cargo install

ENTRYPOINT ["bat"]
CMD []
> docker run -v $(pwd):/tmp bat --color=always /tmp/src/main.rs

@sharkdp
Copy link
Owner

sharkdp commented Oct 10, 2018

Just found this: https://hub.docker.com/r/danlynn/bat/ and https://github.com/danlynn/bat

@danlynn Thank you for creating this! Would you mind if we reference your Docker image here in the README?

@hsudbrock
Copy link
Author

Very nice, thanks @danlynn for providing the image and @sharkdp for posting here :) Very much appreciated!

@danlynn
Copy link

danlynn commented Oct 11, 2018

@sharkdp Please feel free to reference the image. Love supporting your bat project!

@danlynn
Copy link

danlynn commented Oct 11, 2018

Oh! ...and I just released a docker image updated for bat 0.7.1 ;-)

@sharkdp
Copy link
Owner

sharkdp commented Oct 11, 2018

Thanks!

@danlynn
Copy link

danlynn commented Oct 11, 2018

Note that in my updated 0.7.1 image's README, that I recommend the following alias:

alias bat='docker run -it --rm -e BAT_THEME -e BAT_STYLE -e BAT_TABS -v "$(pwd):/myapp" danlynn/bat'

The docker instructions in your new README only passed the BAT_THEME env var (per my old README). So, if you want those additional env vars to be passed through, you might want to update your README.

@sharkdp
Copy link
Owner

sharkdp commented Oct 11, 2018

Updated.

@santosh
Copy link

santosh commented Mar 18, 2021

@sharkdp Was the instruction for Docker based installation removed or was it never there?

@sharkdp
Copy link
Owner

sharkdp commented Mar 27, 2021

It was there, but outdated. I don't really see the need for a Docker-based installation. bat can be installed as a single (statically-linked, if you prefer) binary (see "musl" versions).

It's also available on lots of different package managers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packaging/tooling question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants