Install TerminusDB with Docker on Windows
This guide provides step-by-step instructions for running TerminusDB on Windows using Docker, including how to set up persistent storage, create backups, and connect to DFRNT Cloud.
Prerequisites
Before you begin, ensure you have:
- Docker Desktop for Windows installed and running
- Basic familiarity with Windows Command Prompt or PowerShell
- At least 4GB of RAM allocated to Docker (recommended)
Important: On Windows, the default memory allocated for Docker is 2GB. Since TerminusDB is an in-memory database, it's recommended to increase this allocation in Docker Desktop settings to at least 4GB for optimal performance.
Step 1: Set Up TerminusDB with Docker Volume
In this section, we'll create a directory structure, configure Docker Compose, and set up persistent storage for TerminusDB.
Create the Project Directory
Create a directory to keep your TerminusDB-related files:
mkdir terminusdbLocalhost
cd terminusdbLocalhostCreate docker-compose.yml
Create a file called docker-compose.yml in the terminusdbLocalhost directory:
echo > docker-compose.ymlOpen the file with Notepad and add the following contents:
version: "3.5"
services:
terminusdb-server:
image: terminusdb/terminusdb-server:latest
restart: unless-stopped
ports:
- "127.0.0.1:6363:6363"
environment:
- "TERMINUSDB_SERVER_PORT=6363"
- "TERMINUSDB_ADMIN_PASS=$TERMINUSDB_ADMIN_PASS"
volumes:
- terminusdb_volume:/app/terminusdb/storage
volumes:
terminusdb_volume:
external: trueImportant: Make sure the file has a
.ymlextension only, not.yml.txt, as it will not work otherwise. When running docker-compose commands, you need to be located in theterminusdbLocalhostdirectory.
This configuration tells Docker to:
- Create a container from the latest TerminusDB image
- Attach it to network port 6363 on localhost
- Start automatically when Docker starts (unless manually stopped)
- Read the admin password from an environment variable
- Store data in a persistent Docker volume
Create .env File for Password
Create a .env file in the same directory to store your admin password:
TERMINUSDB_ADMIN_PASS=your_secure_password_hereReplace your_secure_password_here with your desired password.
Security Note: If you use Git to version your files, create a
.gitignorefile immediately and add.envto it to prevent accidentally committing your password:
# .gitignore
.envCreate the Docker Volume
Create a persistent data storage volume for TerminusDB:
docker volume create terminusdb_volumeYou should see the output:
terminusdb_volumeVerify the volume was created:
docker volume lsYou should see:
DRIVER VOLUME NAME
local terminusdb_volumeStart TerminusDB
Start TerminusDB using Docker Compose:
docker-compose up -dWait for TerminusDB to start, then open your browser and navigate to:
http://localhost:6363/Login with:
- Username:
admin - Password: The password you set in the
.envfile
Verify Persistent Storage
To verify that your data is stored in the persistent volume, stop and restart the container:
docker-compose down
docker-compose up -dYour data should persist across container restarts.
Step 2: Backup and Restore TerminusDB
When running TerminusDB on localhost, it's important to keep backup copies of your data to protect against failures.
Important: The backup and restore instructions assume TerminusDB is offline when copying for consistency. Always verify that backup procedures work for your use case before relying on them.
View Volume Contents
You can inspect the contents of your TerminusDB volume using an Ubuntu container:
docker run --rm -it -v terminusdb_volume:/terminusdb ubuntu ls -l ./terminusdb/dbThe --rm flag ensures the temporary Ubuntu container is deleted after the command completes.
Create a Compressed Backup
To create a backup, stop TerminusDB, create a compressed archive, and restart:
For Command Prompt or PowerShell:
docker-compose stop terminusdb-server
docker run --rm -it -v "%CD%":/backup -v terminusdb_volume:/terminusdb ubuntu tar cfz /backup/backup.tar.gz /terminusdb
docker-compose up -d terminusdb-serverFor Git Bash:
docker-compose stop terminusdb-server
MSYS_NO_PATHCONV=1 docker run --rm -it -v "$PWD":/backup -v terminusdb_volume:/terminusdb ubuntu tar cfz /backup/backup.tar.gz /terminusdb
docker-compose up -d terminusdb-serverThis creates a backup.tar.gz file in your current directory.
Restore to a Separate Instance
To restore your backup to a new TerminusDB instance running on a different port:
- Update your
docker-compose.ymlto add a second service:
version: "3.5"
services:
terminusdb-server:
image: terminusdb/terminusdb-server:latest
restart: unless-stopped
ports:
- "127.0.0.1:6363:6363"
environment:
- "TERMINUSDB_SERVER_PORT=6363"
- "TERMINUSDB_ADMIN_PASS=$TERMINUSDB_ADMIN_PASS"
volumes:
- terminusdb_volume:/app/terminusdb/storage
terminusdb-restored:
image: terminusdb/terminusdb-server:latest
restart: unless-stopped
ports:
- "127.0.0.1:6364:6363"
environment:
- "TERMINUSDB_SERVER_PORT=6363"
- "TERMINUSDB_ADMIN_PASS=$TERMINUSDB_ADMIN_PASS"
volumes:
- terminusdb_restored:/app/terminusdb/storage
volumes:
terminusdb_volume:
external: true
terminusdb_restored:
external: true- Create the restore volume and restore the backup:
For Command Prompt or PowerShell:
docker volume create terminusdb_restored
docker run --rm -it -v "%CD%":/restore -v terminusdb_restored:/terminusdb ubuntu tar xvfz /restore/backup.tar.gz
docker run --rm -it -v terminusdb_restored:/terminusdb ubuntu ls -l ./terminusdb/db
docker-compose up -d terminusdb-restoredFor Git Bash:
docker volume create terminusdb_restored
MSYS_NO_PATHCONV=1 docker run --rm -it -v "$PWD":/restore -v terminusdb_restored:/terminusdb ubuntu tar xvfz /restore/backup.tar.gz
MSYS_NO_PATHCONV=1 docker run --rm -it -v terminusdb_restored:/terminusdb ubuntu ls -l ./terminusdb/db
docker-compose up -d terminusdb-restoredThe restored instance will be available at:
http://localhost:6364/Git Bash Considerations
When using Git Bash to run Docker on Windows, path conversion can cause issues. The MSYS_NO_PATHCONV=1 prefix prevents automatic path conversion for Docker commands.
If you encounter path-related errors, ensure you're using the correct command format for your shell environment.
Next Steps
Now that you have TerminusDB running on Windows:
- Connect with the JavaScript Client
- Connect with the Python Client
- Learn about Documents & Schema
- Explore GraphQL Queries