Server configuration for deploying QLever with Docker Swarm and Portainer.
This repository contains Docker Stack configuration files for deploying:
- QLever - A high-performance SPARQL graph database
- Portainer - A container management platform with web UI for managing Docker Swarm
Each stack can be deployed independently or together on the same Docker Swarm cluster.
Deploy QLever SPARQL endpoint and web UI. See the QLever Deployment section below.
Deploy Portainer for managing your Docker Swarm cluster via a web interface. See the Portainer Deployment section below.
This repository includes a Docker Swarm stack for deploying Portainer CE with the Portainer Agent, a container management platform that provides a web-based UI for managing Docker Swarm environments.
- Docker Swarm mode must be initialized on your cluster
- This stack is designed for Docker Swarm (not standalone Docker Compose)
To deploy Portainer using the included stack file:
docker stack deploy -c docker-compose-portainer.yml portainerOnce deployed, you can access Portainer at:
- HTTP: http://localhost:9000
- HTTPS: https://localhost:9443
- Edge Agent: http://localhost:8000
On first launch, you'll need to create an admin account.
Remove the stack:
docker stack rm portainerView services:
docker stack services portainerView logs (for a specific service):
docker service logs portainer_portainer
docker service logs portainer_agentThe Portainer stack includes:
- Portainer Agent: Deployed globally on all Linux nodes, with host filesystem mounted at
/hostfor full environment visibility - Portainer CE: LTS version deployed on manager nodes
- Persistent Storage: Volume for configuration and data persistence
- Network: Overlay network for agent-to-portainer communication
- Ports: 9000 (HTTP), 9443 (HTTPS), and 8000 (Edge Agent)
- Agent Communication: TCP connection between Portainer and agents via port 9001
- Docker Engine 19.03.0+ with Swarm mode enabled
- Portainer CE/EE (optional, but recommended for easier management)
- Sufficient storage space for your RDF datasets
- Minimum 16GB RAM (32GB+ recommended for large datasets)
If you haven't already initialized Docker Swarm:
docker swarm initCreate the required directories for QLever data and cache:
sudo mkdir -p /data/qlever/index
sudo mkdir -p /data/qlever/cache
sudo chmod -R 755 /data/qleverThe stack requires a Docker secret to exist before deployment.
qlever_access_token — authenticates administrative requests to the QLever server (corresponds to the -a flag).
# Generate a strong random token and store it as a Docker secret
printf "$(openssl rand -hex 32)" | docker secret create qlever_access_token -Or create it via Portainer (see Managing Secrets via Portainer below).
export QLEVER_UID=$(id -u) QLEVER_GID=$(id -g)
docker stack deploy -c docker-stack.yml qlever- Log in to your Portainer instance
- Navigate to Stacks in the sidebar
- Click Add stack
- Choose Upload and select
docker-stack.ymlor paste its contents - Name your stack (e.g., "qlever")
- Click Deploy the stack
Before QLever can serve queries, you need to create an index. You can do this by:
- Installing the QLever CLI:
pip install qlever - Creating a Qleverfile for your dataset
- Running the index creation commands
Alternatively, you can exec into the container and manually create the index.
- Port: 7001
- Purpose: Main SPARQL query endpoint
- Image: adfreiburg/qlever:latest
- Resources:
- Limits: 4 CPUs, 32GB RAM
- Reservations: 2 CPUs, 16GB RAM
- Port: 7000
- Purpose: Web-based query interface with autocompletion
- Image: adfreiburg/qlever-ui:latest
- Backend: Connected to qlever service
You can customize the deployment by modifying environment variables in docker-stack.yml:
QLEVER_PORT: Port for the SPARQL endpoint (default: 7001)QLEVER_MEMORY_FOR_QUERIES: Memory allocated for query processing (default: 30G)QLEVER_CACHE_MAX_SIZE: Maximum cache size (default: 10G)QLEVER_BACKEND_URL: URL for the UI to connect to the backend (default: http://qlever:7001)
qlever_data: Stores the RDF index (mounted to/data/qlever/index)qlever_cache: Stores query cache (mounted to/data/qlever/cache)
Note: The volumes are configured as bind mounts. Make sure the directories exist before deploying.
Adjust CPU and memory limits in the deploy.resources section based on your:
- Dataset size
- Expected query load
- Available server resources
After deployment:
- SPARQL Endpoint: http://your-server:7001
- Web UI: http://your-server:7000
Check the status of your stack:
# List services
docker stack services qlever
# View service logs
docker service logs qlever_qlever
docker service logs qlever_qlever-ui
# Check service details
docker service inspect qlever_qleverTo update the stack configuration:
export QLEVER_UID=$(id -u) QLEVER_GID=$(id -g)
docker stack deploy -c docker-stack.yml qleverDocker Swarm will perform a rolling update based on the update configuration.
To scale the QLever service (if needed):
docker service scale qlever_qlever=2Note: Most QLever deployments use a single replica due to the stateful nature of the index.
To completely remove the stack:
docker stack rm qleverWarning: This does not remove the volumes. To remove volumes, use:
docker volume rm qlever_qlever_data qlever_qlever_cache- Check logs:
docker service logs qlever_qlever - Verify directories exist:
/data/qlever/indexand/data/qlever/cache - Ensure sufficient resources are available
The QLever service requires an index to be created before it can serve queries. Follow the index creation steps in the Quick Start section.
If ports 7000 or 7001 are already in use, modify the port mappings in docker-stack.yml:
ports:
- "8001:7001" # Change external portFor production deployments, consider:
- Persistent Storage: Use NFS or other distributed storage for volumes
- Load Balancing: Configure ingress load balancing for multiple replicas
- Secrets Management: Use Docker secrets for sensitive configuration
- Health Checks: Add health check endpoints for better monitoring
- Backup Strategy: Regular backups of
/data/qlever/index
Docker Swarm secrets store sensitive values (like the QLever access token) encrypted and mount them as files inside containers. This stack uses the qlever_access_token secret.
Creating the secret in Portainer:
- Open Portainer and select your Docker Swarm environment
- In the left sidebar, click Secrets
- Click + Add secret
- Set Name to
qlever_access_token - Paste your token value in the Secret field
- Click Add secret
Tip: Generate a secure token with:
openssl rand -hex 32
The secret is mounted at /run/secrets/qlever_access_token inside the container. The qlever service reads it at startup to pass as the -a authentication flag.
For full details on secret rotation and advanced usage, see PORTAINER_DEPLOYMENT.md.
- QLever Main Repository
- QLever CLI Documentation
- QLever Documentation
- Docker Stack Documentation
- Portainer Documentation
This configuration is provided as-is. QLever itself is licensed under Apache 2.0.