> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/zhcndoc/bun/llms.txt
> Use this file to discover all available pages before exploring further.

# Containerize a Bun app with Docker

> Deploy Bun applications using Docker

Bun provides official Docker images for containerizing applications.

## Dockerfile

```dockerfile Dockerfile theme={null}
FROM oven/bun:1 as base
WORKDIR /app

# Install dependencies
COPY package.json bun.lockb ./
RUN bun install --frozen-lockfile

# Copy application code
COPY . .

# Run the app
EXPOSE 3000
CMD ["bun", "run", "server.ts"]
```

## Build and Run

```bash theme={null}
docker build -t my-bun-app .
docker run -p 3000:3000 my-bun-app
```

## Multi-Stage Build

For smaller images:

```dockerfile Dockerfile theme={null}
FROM oven/bun:1 as builder
WORKDIR /app
COPY package.json bun.lockb ./
RUN bun install --frozen-lockfile --production
COPY . .

FROM oven/bun:1-slim
WORKDIR /app
COPY --from=builder /app .
EXPOSE 3000
CMD ["bun", "run", "server.ts"]
```
