Docker is a platform for packaging and running an application as a lightweight, portable container that encapsulates all the necessary dependencies.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/oven-sh/bun/llms.txt
Use this file to discover all available pages before exploring further.
This guide assumes you already have Docker Desktop installed.
Official images
Bun publishes official images to Docker Hub underoven/bun. Several variants are available:
| Tag | Description |
|---|---|
oven/bun:latest | Latest stable release, based on Alpine Linux |
oven/bun:1 | Latest Bun 1.x release |
oven/bun:slim | Minimal Alpine-based image with no extras |
oven/bun:debian | Debian-based image for broader package compatibility |
oven/bun:canary | Latest canary (pre-release) build |
Multi-stage Dockerfile
A multi-stage build separates dependency installation from the final release image, keeping the production image small and fast.Dockerfile
.dockerignore
Create a.dockerignore file to exclude files from the build context. This speeds up builds and prevents secrets from leaking into the image.
.dockerignore
Build and run
Build the image
The
-t flag names the image and --pull ensures Docker downloads the latest base image.Run the container
Run in detached mode (Visit http://localhost:3000 to confirm the app is running.
-d) and map port 3000 on the container to port 3000 on your machine.Docker Compose
For local development with multiple services, use Docker Compose:docker-compose.yml
Health checks
Add a health check endpoint to your Bun server so Docker can monitor the container:index.ts
HEALTHCHECK instruction in the Dockerfile (or the healthcheck key in Compose) will poll this endpoint and mark the container as unhealthy if it fails.