Yet another Apache Fuseki Docker distribution.
The Docker image provided by this distribution shall:
- Allow the full Fuseki configuration
- Allow adding extensions
- Use Maven to get an up-to-date version of Fuseki
- Be extendible to allow creation of custom distributions as extending images
docker build -t linkedsolutions/fuseki-base .
docker-compose up
or
docker run --rm -v `pwd`/base:/fuseki/base -p 3030:3030 linkedsolutions/fuseki-base
You might have 'pwd
/base' with the full path to the FUSEKI_BASE directory, see
https://jena.apache.org/documentation/fuseki2/fuseki-layout.html to learn about the contents of this directory.
The image starts by default with a minimal configuration file at /config.ttl
that defines an empty Fuseki server with no datasets. This allows Fuseki to start successfully while providing a base for customization.
You can mount a local folder at the container path /fuseki/base
and put any fuseki configuration file in that folder. When the image is run for the first time a default configuration is created in that directory. With this default configuration the
environment variable ADMIN_PASSWORD
can be used to set the password of the admin user
on startup.
To use a custom configuration, simply mount your configuration file at /config.ttl
:
-v $(pwd)/my-config.ttl:/config.ttl
Any jar in the folder at the container path /fuseki/extensions
is added to the classpath.
Any script in the folder at the container path /fuseki/set-up-scripts
is executed when the container is started without shiro.ini
file in the FUSEKI_BASE directory. These allows extending images to provide additional default configuration.
All example files mentioned in this documentation are available in the examples/
directory.
Build the Docker image first:
docker build -t linkedsolutions/fuseki-base .
# In-memory dataset
docker run --rm -p 3030:3030 linkedsolutions/fuseki-base \
sh -c "java \$JAVA_OPTS -cp /fuseki/home/fuseki.jar org.apache.jena.fuseki.cmd.FusekiCmd --mem --port 3030 /books"
# Persistent TDB dataset (create directory first: mkdir -p ./fuseki-data/databases/books)
docker run --rm -p 3030:3030 \
-v $(pwd)/fuseki-data:/fuseki-data \
linkedsolutions/fuseki-base \
sh -c "java \$JAVA_OPTS -cp /fuseki/home/fuseki.jar org.apache.jena.fuseki.cmd.FusekiCmd --loc=/fuseki-data/databases/books --update --port 3030 /books"
curl -X POST -H "Content-Type: text/turtle" \
--data-binary "@examples/sample-data.ttl" \
"http://localhost:3030/books/data"
# Query people
curl -X POST -H "Content-Type: application/sparql-query" \
--data-binary "@examples/query-people.sparql" \
"http://localhost:3030/books/query"
# Query books
curl -X POST -H "Content-Type: application/sparql-query" \
--data-binary "@examples/query-books.sparql" \
"http://localhost:3030/books/query"
curl -X POST -H "Content-Type: application/sparql-update" \
--data-binary "@examples/insert-data.sparql" \
"http://localhost:3030/books/update"
# Using a custom configuration file (replaces the default /config.ttl)
docker run --rm -p 3030:3030 \
-v $(pwd)/fuseki-data:/fuseki/base \
-v $(pwd)/examples/config.ttl:/config.ttl \
linkedsolutions/fuseki-base
# Or run with the default minimal configuration (no datasets)
docker run --rm -p 3030:3030 \
-v $(pwd)/fuseki-data:/fuseki/base \
linkedsolutions/fuseki-base
services:
fuseki:
image: "linkedsolutions/fuseki-base"
ports:
- "3030:3030"
volumes:
- ./fuseki-data:/fuseki/base
- ./examples/config.ttl:/config.ttl # Override default config
environment:
- ADMIN_PASSWORD=your-secure-password
docker run --rm -p 3030:3030 \
-v $(pwd)/fuseki-data:/fuseki-data \
-v $(pwd)/examples/config-lucene.ttl:/config.ttl \
linkedsolutions/fuseki-base
curl -X POST -H "Content-Type: text/turtle" \
--data-binary "@examples/lucene-data.ttl" \
"http://localhost:3030/books/data"
curl -X POST -H "Content-Type: application/sparql-query" \
--data-binary "@examples/query-text-search.sparql" \
"http://localhost:3030/books/query"
With the same dataset name (/books
), you can see the difference:
Regular SPARQL query (works without Lucene):
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?book ?title WHERE {
?book dc:title ?title .
FILTER(CONTAINS(LCASE(?title), "sparql"))
}
Text search query (requires Lucene configuration):
PREFIX text: <http://jena.apache.org/text#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?book ?score ?title WHERE {
(?book ?score) text:query "SPARQL" .
?book dc:title ?title .
}
The text search provides relevance scoring and performs much better on large datasets.
Fuseki provides a web interface at http://localhost:3030
where you can:
- Browse datasets
- Execute SPARQL queries interactively
- Upload data files
- Monitor server statistics
- Manage dataset configurations
200 OK
: Successful query/operation204 No Content
: Successful update with no response body400 Bad Request
: Malformed SPARQL or invalid data401 Unauthorized
: Authentication required404 Not Found
: Dataset or endpoint not found500 Internal Server Error
: Server error (check logs)
- Data Formats: Fuseki supports RDF/XML, Turtle, N-Triples, JSON-LD, and more
- Authentication: Use HTTP Basic Auth for protected endpoints
- Performance: Use TDB for better performance with large datasets
- Monitoring: Check server logs and the
/$/stats
endpoint for monitoring - Backup: Regularly backup your TDB database directories
- Text Search: Full-text search with Lucene is now included by default
- Memory: Increase JVM memory with
JAVA_OPTS="-Xmx4g"
for large datasets - Security: Always change default passwords in production environments