How to run DBLab Engine on macOS
This guide explains how to run the DBLab Engine with full ZFS support on macOS, using Colima, a lightweight Linux VM with Docker support.
All ZFS operations happen inside the Colima VM, so you don't need to install the ZFS module to your macOS.
This guide provides an experimental way to run DBLab Engine on macOS.
Prerequisites: Docker, Colima, Go
First, install Homebrew, if you don't have it yet:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Then install Docker, Colima, and Go:
brew install docker colima go
To build the DLE binary locally, Go 1.23 or higher is required, so let's check Go version:
go version
If your Go version is older than 1.23, update it:
brew update
brew upgrade go
1. Get DBLab source code
git clone https://gitlab.com/postgres-ai/database-lab.git
cd database-lab/engine
2. Start Colima VM
Run Colima with enough resources and mount your project directory (adjust parameters based on available resources):
colima start --cpu 4 --memory 6 --disk 20 --mount $HOME:w
The --mount $HOME:w
flag makes your home directory accessible inside Colima at /mnt/host/Users/yourname/...
.
3. Initialize ZFS in Colima VM
You can either use the provided setup script or run all steps manually if you prefer better control.
- Option 1: Run the setup script
- Option 2: Manual setup (inside Colima)
# to run this, we must be in `./engine` subdirectory
colima ssh < ./scripts/init-zfs-colima.sh
This will:
- Install
zfsutils-linux
if needed - Create a loop device-backed ZFS pool (
dblab_pool
) - Create default datasets:
dataset_1
,dataset_2
,dataset_3
Step 1. Open Colima shell from your macOS terminal:
colima ssh
Step 2. Install ZFS:
sudo apt-get update
sudo apt-get install -y zfsutils-linux
Step 3. Create a virtual disk:
Specify desired disk size (e.g. 5G
, 10G
, 20G
) and create a virtual disk:
DISK_SIZE=20G
sudo mkdir -p /var/lib/dblab
sudo truncate -s "$DISK_SIZE" /var/lib/dblab/zfs-disk
This creates an empty file at /var/lib/dblab/zfs-disk
, which will be used as a virtual block device for the ZFS pool.
Step 4. Set up a loop device:
sudo losetup -fP /var/lib/dblab/zfs-disk
LOOP=$(sudo losetup -j /var/lib/dblab/zfs-disk | cut -d: -f1)
Step 5. Create a ZFS pool:
sudo zpool create -f \
-O compression=on \
-O atime=off \
-O recordsize=128k \
-O logbias=throughput \
-m /var/lib/dblab/dblab_pool \
dblab_pool \
"$LOOP"
Step 6. Create base datasets:
sudo zfs create -o mountpoint=/var/lib/dblab/dblab_pool/dataset_1 dblab_pool/dataset_1
sudo zfs create -o mountpoint=/var/lib/dblab/dblab_pool/dataset_2 dblab_pool/dataset_2
sudo zfs create -o mountpoint=/var/lib/dblab/dblab_pool/dataset_3 dblab_pool/dataset_3
Step 7. Verify:
zfs list
You should see datasets similar to this:
NAME USED AVAIL REFER MOUNTPOINT
dblab_pool 0B 20G 96.5K /var/lib/dblab/dblab_pool
dblab_pool/dataset_1 0B 20G 96.5K /var/lib/dblab/dblab_pool/dataset_1
dblab_pool/dataset_2 0B 20G 96.5K /var/lib/dblab/dblab_pool/dataset_2
dblab_pool/dataset_3 0B 20G 96.5K /var/lib/dblab/dblab_pool/dataset_3
Step 8. Exit Colima shell:
exit
4. Build engine
Compile DBLab Engine binary for Linux:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o bin/dblab-server ./cmd/database-lab/main.go
5. Build Docker image
docker build -t dblab_server:local -f Dockerfile.dblab-server .
6. Configure your DBLab Engine
Before running the server, create your configuration file:
cp configs/config.example.logical_generic.yml configs/server.yml
Then edit configs/server.yml
and make the following changes:
- Set the ZFS mount path to
/var/lib/dblab/dblab_pool
:This should match the dataset mount path used by the ZFS pool.mountDir: /var/lib/dblab/dblab_pool
- Configure connection to the source database:
connection:
dbname: postgres
host: localhost
port: <port>
username: postgres
password: your_password
7. Run DBLab main container
docker run \
--rm \
--name dblab_server \
--privileged \
--device /dev/zfs \
-v /tmp:/tmp \
-v /var/lib/dblab/dblab_pool:/var/lib/dblab/dblab_pool:rshared \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /var/run/zfs.sock:/var/run/zfs.sock \
-v "$(pwd)/configs:/home/dblab/configs:rw" \
-v "$(pwd)/configs/standard:/home/dblab/standard:ro" \
-v "$(pwd)/meta:/home/dblab/meta" \
--env DOCKER_API_VERSION=1.39 \
-p 2345:2345 \
dblab_server:local
Open DBLab UI
When the main container (dblab_server
) starts, it launches an additional container with UI, whose name looks like dblab_embedded_ui_xxx
; it provides UI available at port 2346
by default (can be changed in server.yml
).
In your browser, open http://localhost:2346.
You'll see a "refreshing" state while the engine initializes. This may take some time; please wait until the refresh is complete. Once it's done, you will be able to create snapshots, branches, clones.
8. Cleanup (optional)
Stop the container:
docker stop dblab_server
docker rm -f dblab_server
Ensure no extra containers (UI, Postgres) that were launched by dblab_server
, are present (if there are, delete them using docker rm
):
docker ps -a \
--format "ID: {{.ID}}\tName: {{.Names}}\tImage: {{.Image}}\tLabels: {{.Labels}}" \
| grep dblab
Stop Colima VM:
colima stop
Reset everything (⚠️ this wipes Colima VM, ZFS pool, images):
colima delete