Files
bknd/docs/integration/docker.mdx
2025-07-03 15:05:49 +02:00

88 lines
2.3 KiB
Plaintext

---
title: 'Docker'
description: 'Official docker image for bknd'
---
# Official `bknd` Docker image
The docker image intentially doesn't copy any data into the image for now, so you can copy the Dockerfile and build the image anywhere.
Locate the Dockerfile either by pulling the [repository](https://github.com/bknd-io/bknd) and navigating to the `docker` directory, or download from [here](https://github.com/bknd-io/bknd/blob/main/docker/Dockerfile).
## Building the Docker image
To build the Docker image, run the following command:
```bash
docker build -t bknd .
```
If you want to override the bknd version used, you can pass a `VERSION` build argument:
```bash
docker build --build-arg VERSION=<version> -t bknd .
````
```bash
## Running the Docker container
To run the Docker container, run the following command:
```bash
docker run -p 1337:1337 bknd
```
You can pass the same CLI arguments (see [Using the CLI](https://docs.bknd.io/cli) guide) to the docker container as you'd do with `npx bknd run`, like so:
```bash
docker run -p 1337:1337 -e ARGS="--db-url file:/data/data.db" bknd
```
Or connect to a remote turso database:
```bash
docker run -p 1337:1337 -e ARGS="--db-url libsql://<db>.turso.io --db-token <token>" bknd
```
To mount the data directory to the host, you can use the `-v` flag:
```bash
docker run -p 1337:1337 -v /path/to/data:/data bknd
```
## Docker compose example
If you want to use docker compose and build the image directly from the git repository.
`compose.yml`
```yaml
services:
bknd:
pull_policy: build
build: https://github.com/bknd-io/bknd.git#main:docker
ports:
- 1337:1337
environment:
ARGS: "--db-url file:/data/data.db"
volumes:
- ${DATA_DIR:-.}/data:/data
```
The docker compose can be extended to build a specific version of bknd.
Extend the build command with `args` and `labels`.
Within the args you can pass a `VERSION` build argument.
and labels will ensure that the image that has been build a unique identifier has.
`compose.yml`
```yaml
services:
bknd:
pull_policy: build
build:
context: https://github.com/bknd-io/bknd.git#main:docker
args:
VERSION: <version>
labels:
- x-bknd-version=<version>
ports:
- 1337:1337
environment:
ARGS: "--db-url file:/data/data.db"
volumes:
- ${DATA_DIR:-.}/data:/data
```