Link Search Menu Expand Document
Start for Free

Docker-specific Operations

This page describes specific operations you can perform while running Stardog in Docker.


Use Stardog Admin CLI

The Stardog Admin CLI (stardog-admin) and Stardog CLI (stardog) can be run locally within a container using the following command:

# stardog-admin
docker exec -it <containerID/name> stardog-admin <command> [options]
# stardog
docker exec -it <containerID/name> stardog <command> [options]

The -it options give you an interactive terminal inside the container, which lets you handle commands that prompt for credentials or other interactive input. If you know a specific command will not request input, you can omit -it.

To determine the container ID or name, run docker ps to list the currently running Docker containers.

For more information about the Stardog Admin and Stardog CLI commands, see the Command Line Interface documentation or the man pages: (stardog-admin, stardog)

Example: Create a new Stardog database

Run the following command to create a new database named myDb:

docker exec -it <containerID/name> stardog-admin db create -n myDb

Example: Import data into a Stardog database

This example assumes you have a named volume stardog-home mounted to /var/opt/stardog (the default Stardog home inside the container) and that it contains a file called data.ttl in the import directory. For more on mounting a named volume, see here.

Use the following command to import data into your database myDb:

docker exec -it <containerID/name> stardog data add myDb /var/opt/stardog/import/data.ttl

If you mounted the file into a different container path (for example /import), update the command to match that location.

Example: Exporting data from a Stardog database

Use the following command to export data from the database myDb:

docker exec -it <containerID/name> stardog data export --named-graph ALL -- myDb

Generate a diagnostics report

To generate a diagnostics report, use the following command:

docker exec -it <containerID/name> stardog-admin diagnostics report  --output /var/opt/stardog/stardog-diagnostics.zip

Use Stardog CLI for querying

Run SPARQL queries directly within your Docker container using the Stardog CLI:

docker exec -it <containerID/name> stardog query execute myDb "SELECT * WHERE { ?s ?p ?o } LIMIT 10"

Example: Pass a SPARQL query file into a Stardog Docker container

Mount a local directory with your SPARQL queries when starting your container:

docker run -it --rm \
    --volume /path/to/local/queries:/var/opt/stardog/queries \
    --publish=5820:5820 \
    stardog/stardog

Execute a SPARQL query from a file:

docker exec -it <containerID/name> stardog query execute myDb /var/opt/stardog/queries/example.sparql

Example: Pipe a query file into Stardog

You can also pipe SPARQL queries into Stardog directly from your host:

cat example.sparql | docker exec --interactive <containerID/name> stardog query execute myDb

These commands demonstrate basic administrative operations for managing and interacting with Stardog using Docker.