Use bun from a Docker container

A guide on how to use Bun from inside a Docker container

Jose Garcia
2 min readSep 13, 2023
An image of cute buns
Image by we-o_rd35laag_nsqqn91c from Pixabay

We all have seen the Bun hype and their new all-in-one tool. Blazingly fast, they say.

And I know I know. I am also a little touchy about my computer being clean. The less bloatware the better I say. That’s why we are throwing Docker into the mix here.

No more talking, let’s get to it.

Move inside the project in which you want to try it and run:

docker run --network host --interactive --tty --rm -v $(pwd):/app -w /app oven/bun

To be clear, you have to append the script to the command. So for example if you have a start script in an Express project, you should run:

docker run --network host --interactive --tty --rm -v $(pwd):/app -w /app oven/bun run start

That’s it. You should be running Bun with Docker now.

Bonus

As a bonus, you can make an alias.

In your .bashrc or .bash_aliases file add the following:

alias bun="docker run --network host --interactive --tty --rm -v $(pwd):/app -w /app localhost/oven/bun"

If you want to know more about aliases, check this:

And if you want to know more about how the command works, check this:

Short and sweet. I hope you enjoy your bun!

--

--

Jose Garcia

Hello There! I am a fullstack developer, a fan of open source and crypto and an obssesive fella. Well met.