Bat: Provide a docker image for running this command without installation

Created on 5 Oct 2018  路  11Comments  路  Source: sharkdp/bat

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.)

packagintooling question

All 11 comments

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? :smile:

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.

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!

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

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?

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

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

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

Thanks!

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.

Updated.

Was this page helpful?
0 / 5 - 0 ratings