In this post, I provide a procedure for setting up Carbon LDP with Stardog as the database, from scratch. Further documentation can be found on the product documentation page, Enterprise-class repositories. This procedure will detail how to run both Carbon LDP and Stardog together as two linked Docker containers.

Obtain Stardog and license key file

To create the Stardog container, you will need the Stardog binary and a license key. Head over to stardog.com and fetch yourself the 30-day Enterprise trial or Community Edition.

Setup the Stardog docker container

First, we’ll setup the Stardog container. For this, we’ll use Jon Tutcher’s Stardog dockerfile. Use the following command to get Jon’s repo. In my case, I am providing a new name for the local repo (stardog-docker-jontutcher).

git clone https://github.com/jontutcher/stardog-docker.git stardog-docker-jontutcher

Navigate into the directory and create a resources directory inside of it…

cd stardog-docker-jontutcher/
mkdir resources

Put the Stardog license key file into the resources directory. The file must be named stardog-license-key.bin. You can obtain a license key for the 30 day enterprise trial or community edition at stardog.com. The license key will be picked up from the resources directory and built into the image when we build from the dockerfile.

Back out of the resources directory and run the docker build command.

cd ..
docker build --tag stardog:latest .

Now use the following command to run the container.

docker run \
    -d -p 5820:5820 \
    --name stardog-instance \
    -v /Users/cburleson/data/stardog:/stardog \
    stardog:latest

Note that the -v parameter should point to your Stardog data directory on your host machine. If you do not have an existing Stardog data directory, you should create an empty one and refer to that.

You can use the following command to verify the container exists and is running:

docker ps -a

In your web browser, navigate to http://localhost:5820/ to access the Stardog administrative interface. You can login with the default username and password: admin | admin. Alternatively, you can access Stardog through Stardog Studio, a separate download.

Create a database in Stardog for Carbon LDP

Next, we’ll create a database in the Stardog server for the Carbon platform to use. Through the web interface, you can do this through Databases > New DB. Create a new database with all the default options except for “Database online”, which you should switch to OFF. This will allow us to edit the database configuration directly after creating it. Name the database whatever you want, such as “carbonldp”. In my case, I’m using the name “carbonldp-industrial” for the industrial PoC I’m building.

After creating the database, edit it and set Query all graphs to ON, which is necessary for Carbon to function properly.

Now Save the database configuration and turn the database ON.

Configure and run the Carbon LDP platform container

Spinning up a Carbon LDP platform container requires only one docker command. But first, you need to…

Create a persistent volume for Carbon LDP

Create a directory on your local machine that can be used as a persistent volume for the Carbon platform container. In my case, I created the following directory, for example:

/Users/cburleson/data/carbonldp-industrial

Run the Carbon LDP container

The prerequisites are set. So, now we can spin up a Carbon server with the following Docker command. Be sure to replace the -v parameter with the path you created for your persistent Carbon directory. Leave everything after the colon in tact (don’t touch the part, :/opt/carbonldp/shared). At the time of this writing, the latest version of Carbon is 1.0.x-alpha. If there is a later version by the time you read this, you can use that. Also be sure to change the name of the carbonldp.repository.id parameter to the name of the database you created for Carbon in the Stardog server. You can name the container whatever you want. It’s typical to call it “carbonldp”, but in my case, I’m running it with the container named “carbonldp-industrial” This allows me to have multiple carbon containers for different purposes. As per my own settings, the full command is as follows:

docker run -d --name carbonldp-industrial -p 8083:8083 \
    -v /Users/cburleson/data/carbonldp-industrial:/opt/carbonldp/shared \
    --link stardog-instance:stardog-instance carbonldp/carbonldp-platform:1.0.x-alpha \
    --carbonldp.repository.type="stardog" \
    --carbonldp.repository.url="http://stardog-instance:5820/" \
    --carbonldp.repository.username="admin" \
    --carbonldp.repository.password="admin" \
    --carbonldp.repository.id="carbonldp-industrial"

In order for the two containers to communicate with one another, they are linked with Docker link parameter.  The value of that parameter is the container (<name or id>:alias or <name or id>). In my case, stardog-instance:stardog-instance, where stardog-instance is the name of the Stardog container and also referred to in the carbonldp.repository.url value.

If the Carbon image is not yet present on your machine, it will be fetched by the command from Docker Hub. You can execute the following Docker command to verify that the container is up and running.

docker ps -a

Is the STATUS is Exited, there was a problem in the startup. If you see such a problem, you can run the following command to examine the logs for troubleshooting:

docker logs <container-name>

Or, in my case…

docker logs carbonldp-industrial

If Carbon started up successfully, its logs should resemble the following:

┌----------------------------------------------------------------------------------------------------┐

                                                ssss,
                                                sssss
      ,.-::/::-.,     ,.-::/::., .--- ,---,,-:, sssss ,-::/::-.,     ,.-::/::-.,   ,---. ,.::/::.,
   ,-+ossssssssso+. -+osssssssso/+sss :sss+osss ssss:+ssssssssso/. -+ossssssssss+: :sss+/ossssssso-.
  -ossso/:---:/os+ +ssso+:---:+osssss :ssss+:-: sssssso/----:+ssss+ oso+:----/ossso :ssss+/:-:/ossso.
 -ssss:`       `: osss/`       `/ssss :sss+     sssso-        .ossso /`       `-osss :ss-      `/ssso
 osss/           +sss+           +sss :sss+     ssss-          `ssss            -ssss o+        `ssss
 ssss:           osss/           :sss :sss+     ssss.           ssss            .ssss o/        `ssss
 /ssso.          +ssso.         .osss :sss+     ssss+,         :ssss           `+ssso s/        `ssss
 `+ssso/.,   ,./o +ssso/.,   ,./ossss :sss+     ssssso:,    ,-+ssss: o/.,   ,.:ossso +s/        `ssss
   -ossssooooossso -ossssooooosssosss :sss+     ssssosssooooossss+. ssssooooosssso: oss/        `ssss
     .:/oossso+/-`   .:+osssso/:`:+++ -+++:     ++++`./+ossso+/-`   `:/+osssoo+:.  -+++:        `++++

├┬---------------------------------------------------------------------------------------------------┤
 ¦ Platform: v1.0.0-alpha.13 (Build: 2018-04-12T16:39:27+0000)
 ¦
 ¦ https://carbonldp.com
└┴---------------------------------------------------------------------------------------------------┘

INFO  [                         c.c.Application] -- Starting Application v1.0.0-alpha.13 on 6a8195e0e2e2 with PID 7 (/opt/carbonldp/carbonldp-platform.jar started by root in /)
DEBUG [                         c.c.Application] -- Running with Spring Boot v2.0.1.RELEASE, Spring v5.0.5.RELEASE
INFO  [                         c.c.Application] -- The following profiles are active: default
DEBUG [c.c.r.t.TxnConfig$$EnhancerBySpringCGLIB$$5dca10a3] -- Connecting with configured Stardog repository...
DEBUG [c.c.r.t.TxnConfig$$EnhancerBySpringCGLIB$$5dca10a3] -- Connecting with configured Stardog repository...DONE
DEBUG [                     c.c.l.LockingConfig] -- Starting embedded ZooKeeper server...
DEBUG [                     c.c.l.LockingConfig] -- Starting embedded ZooKeeper server...COMPLETE
DEBUG [   c.c.s.a.t.JWTokenAuthenticationFilter] -- Initializing filter 'jwTokenAuthenticationFilter'
DEBUG [   c.c.s.a.t.JWTokenAuthenticationFilter] -- Filter 'jwTokenAuthenticationFilter' configured successfully
DEBUG [ c.c.s.a.a.AnonymousAuthenticationFilter] -- Initializing filter 'anonymousAuthenticationFilter'
DEBUG [ c.c.s.a.a.AnonymousAuthenticationFilter] -- Filter 'anonymousAuthenticationFilter' configured successfully
INFO  [                         c.c.Application] -- Started Application in 11.816 seconds (JVM running for 13.061)

Verify Carbon data in the Stardog server

For an additional validation, you can verify that the database in Stardog has some preliminary Carbon-specific data in it. In the Stardog web console at http://localhost:5820/, navigate to the database you created for Carbon, click on >_ Query and run the following SPARQL query for Types:

select distinct ?type ?label 
where { 
  ?s a ?type . 
  OPTIONAL { ?type rdfs:label ?label } 
}

You should see Carbon-specific types in the results as shown below…

Verify Carbon response in web browser

You can also do a check for a response from the Carbon server by hitting the following URL in your web browser:

http://localhost:8083/.system/platform/

The browser should return an RDF response similar to the following (the platform meta, which includes the build date and version):

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <rdf:Description rdf:about="http://localhost:8083/.system/platform/">
    <rdf:type rdf:resource="http://www.w3.org/ns/ldp#Container"/>
    <rdf:type rdf:resource="https://carbonldp.com/ns/v1/platform#RequiredSystemDocument"/>
    <rdf:type rdf:resource="http://www.w3.org/ns/ldp#RDFSource"/>
    <rdf:type rdf:resource="http://www.w3.org/ns/ldp#BasicContainer"/>
    <rdf:type rdf:resource="http://www.w3.org/ns/ldp#Resource"/>
    <rdf:type rdf:resource="https://carbonldp.com/ns/v1/platform#Document"/>
    <rdf:type rdf:resource="https://carbonldp.com/ns/v1/platform#Platform"/>
    <membershipResource xmlns="http://www.w3.org/ns/ldp#" rdf:resource="http://localhost:8083/.system/platform/"/>
    <modified xmlns="https://carbonldp.com/ns/v1/platform#" rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2018-07-17T20:06:25.656Z</modified>
    <created xmlns="https://carbonldp.com/ns/v1/platform#" rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2018-07-17T20:06:25.656Z</created>
  </rdf:Description>
  <rdf:Description rdf:nodeID="node1ciktjenqx53">
    <rdf:type rdf:resource="https://carbonldp.com/ns/v1/platform#PlatformInstance"/>
    <rdf:type rdf:resource="https://carbonldp.com/ns/v1/platform#VolatileResource"/>
    <buildDate xmlns="https://carbonldp.com/ns/v1/platform#" rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2018-04-12T16:39:27.000Z</buildDate>
    <version xmlns="https://carbonldp.com/ns/v1/platform#">1.0.0-alpha.13</version>
  </rdf:Description>
    <rdf:Description rdf:about="http://localhost:8083/.system/platform/">
    <instance xmlns="https://carbonldp.com/ns/v1/platform#" rdf:nodeID="node1ciktjenqx53"/>
  </rdf:Description>
</rdf:RDF>

You’re good to go! You may, however, wish to use the Carbon LDP Workbench as well.

Run the Carbon LDP Workbench

The Carbon LDP Workbench provides a visual interface to your Carbon instance data. You can spin up the workbench with the following command:

docker run -d --name carbonldp-workbench -p 8000:80 \
    -e "CARBON_HOST=localhost:8083" \
    -e "CARBON_PROTOCOL=http" \
    carbonldp/carbonldp-workbench:1.0.x-alpha

You can then access the Workbench at the following URL:

http://localhost:8000/

If you see any errors in the Workbench when first accessing it, try a hard refresh in your browser.

Accessing the Stardog container’s shell

If you want to get into the Stardog container to execute stardog-admin commands, use the following Docker command:

docker exec -it <stardog-container-name> bash

In my case:

docker exec -it stardog-instance bash

Then you can change into the stardog/bin directory…

cd /stardog/bin

And execute stardog-admin commands, such as…

./stardog-admin help

You can type exit to exit out of the container and back to your host shell.

Accessing the Carbon LDP container’s shell

If you want to get into the Carbon LDP container, you can use a similar command. However, the Carbon container does not include bash, so you can use sh instead…

docker exec -it <carbon-container-name> sh

You can type exit to exit out of the container and back to your host shell.

Conclusion

This post described the procedure for setting up a Carbon LDP container configured to run with a Stardog database in a Stardog container. Additionally, we setup the Carbon LDP Workbench. And finally, I showed how you can get inside the Stardog container to execute stardog-admin commands. The procedure results in three Docker containers providing everything you need for Carbon LDP with Stardog development environment.

 

When developing with the Carbon LDP JavaScript SDK and using the sparqler library, you could stumble upon the error: Error: The used prefix has not been declared. In one case where I generated this error, the complete console error was as follows:

ExploreComponent.html:48 ERROR Error: The used prefix has not been declared
    at IRIResolver.push../node_modules/sparqler/iri/IRIResolver.js.IRIResolver.resolve (IRIResolver.js:23)
    at TriplesPattern.js:69
    at Array.reduce ()
    at Variable.push../node_modules/sparqler/patterns/triples/TriplesPattern.js.TriplesPattern._resolvePath (TriplesPattern.js:57)
    at Variable.push../node_modules/sparqler/patterns/triples/TriplesPattern.js.TriplesPattern._addPattern (TriplesPattern.js:33)
    at Variable.push../node_modules/sparqler/patterns/triples/TriplesPattern.js.TriplesPattern.has (TriplesPattern.js:14)
    at explore.service.ts:248
    at Array.forEach ()
    at ExploreService.push../src/app/services/explore.service.ts.ExploreService._constructFiltersPatterns (explore.service.ts:238)
    at explore.service.ts:115

The problem was with the following offending line in my code:

filterPatterns = _.var(subjectName).has(filter.property.id, _.literal(filter.object).ofType(filter.property.range));

The filter.property.id string was being interpreted as a prefix and the fix was to wrap filter.property.id with the _.resource() method of the PatternBuilder utility like this:

_.resource(filter.property.id)

This made it so that a string such as https://example.com/ would be reflected instead as <https://example.com/>.

General information about querying can be found in the Carbon LDP product documentation on Querying.

Example SPARQL queries that can help you list the classes in an ontology.

List all classes

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
  
SELECT DISTINCT ?type
WHERE {
  ?s a ?type.
}

Note: The SPARQL keyword a is a shortcut for the common predicate rdf:type, giving the class of a resource.

List root classes

SELECT ?directSub ?super
 WHERE { ?directSub rdfs:subClassOf ?super .
         FILTER NOT EXISTS {
            ?directSub rdfs:subClassOf ?otherSub .
            FILTER (?otherSub != ?directSub)
         }
}

List all classes with a given prefix

PREFIX bc: <http://base22.com/ont/bc#>
 
SELECT DISTINCT ?type
WHERE {
  ?subject a ?type.
  FILTER( STRSTARTS(STR(?type),str(bc:)) )
}

List class hierarchy

PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
 
 
SELECT DISTINCT ?subject ?label ?supertype
WHERE {
    { ?subject a owl:Class . } UNION { ?individual a ?subject . } .
    OPTIONAL { ?subject rdfs:subClassOf ?supertype } .
    OPTIONAL { ?subject rdfs:label ?label }
} ORDER BY ?subject

Note that when a reasoner is enabled classes may typically be inferred to be rdfs:subClassOf themselves and rdfs:subClassOf any parent class, not just the direct parent.

List class hierarchy – filtered

Give a class hierarchy, but filter out several structural elements so that we only end up with the unique classes in our ontology.

PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?subject ?label ?supertype
WHERE {
    { ?subject a owl:Class . } UNION { ?individual a ?subject . } .
    OPTIONAL { ?subject rdfs:subClassOf ?supertype } .
    OPTIONAL { ?subject rdfs:label ?label }.
    FILTER (?subject != owl:Class &&
        ?subject != rdf:List &&
        ?subject != rdf:Property &&
        ?subject != rdfs:Class &&
        ?subject != rdfs:Datatype &&
        ?subject != rdfs:ContainerMembershipProperty &&
        ?subject != owl:DatatypeProperty &&
        ?subject != owl:NamedIndividual &&
        ?subject != owl:Ontology )
} ORDER BY ?subject

Note that when a reasoner is enabled classes may typically be inferred to be rdfs:subClassOf themselves and rdfs:subClassOf any parent class, not just the direct parent.

List class hierarchy with direct subclasses only

This is similar to the query above, but uses the Sesame-specific sesame:directSubClassOf to get only direct subclasses. This would work in any RDF4J (formerly Sesame) system such as Graph DB.

PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX : <http://codyburleson.com/hyperg/>
 
SELECT DISTINCT ?subject ?label ?supertype
WHERE {
    {
        ?subject a owl:Class .
        OPTIONAL { ?subject sesame:directSubClassOf ?supertype } .
        OPTIONAL { ?subject rdfs:label ?label }.
    }
           
          FILTER (?subject != owl:Class &&
            ?subject != rdf:List &&
            ?subject != rdf:Property &&
            ?subject != rdfs:Class &&
            ?subject != rdfs:Datatype &&
            ?subject != rdfs:ContainerMembershipProperty &&
            ?subject != owl:DatatypeProperty &&
            ?subject != owl:NamedIndividual &&
            ?subject != owl:Ontology &&
            ?subject != ?supertype)
} ORDER BY ?subject

 

SPARQL examples – construct

Construct a graph giving ontology structure (the class hierarchy, properties, domains and ranges)

CONSTRUCT { ?s ?p ?o . } 
WHERE { VALUES ?p { rdfs:subClassOf rdfs:subPropertyOf rdfs:domain rdfs:range} ?s ?p ?o }

Note that when a reasoner is enabled classes may typically be inferred to be rdfs:subClassOf themselves and rdfs:subClassOf any parent class, not just the direct parent.

SPARQL examples – select

Find all triples

Use SELECT to signify you want to SELECT certain information and WHERE to signify your conditions, restrictions, and filters. A limit is used to avoid cracking the server on a large dataset.

SELECT ?subject ?predicate ?object
WHERE {?subject ?predicate ?object} 
LIMIT 100

Find all same-subject triples by given subject

By specifying only the subject in the pattern, we can return all triples that have that subject. When an individual entity is defined by a given subject URI, then this is a way to get all the properties for that entity.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?subject ?predicate ?object
WHERE {
    <http://codyburleson.com/hyperg/person/cody-burleson> ?predicate ?object .
} LIMIT 100

Since the subject is known, it may typically only be necessary to return the ?predicate and ?object in the SELECT line (omitting ?subject)

Find and order most used predicates

SELECT ?predicate (COUNT(*)AS ?frequency)
WHERE {?subject ?predicate ?obDEject}
GROUP BY ?predicate
ORDER BY DESC(?frequency)
LIMIT 10

Select the top 100 nodes in the RDF graph

RDF Rank is a GraphDB extension. It is similar to Page Rank and it identifies “important” nodes in an RDF graph based on their interconnectedness. It is accessed using the rank:hasRDFRank system predicate.

PREFIX rank:<http://www.ontotext.com/owlim/RDFRank#>
SELECT ?n
WHERE {?n rank:hasRDFRank ?r }
ORDER BY DESC(?r)
LIMIT 100

Find anything with a label

The following query will find all triples where subject and object are joined by rdfs:label. In other words, anything that has been defined as having a label.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?subject ?label
WHERE { ?subject rdfs:label ?label } LIMIT 100

Find instances by class with a label

The following example query will get the labels of anything of the class type (rdf:type) Organization.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?subject ?label
WHERE {
    ?subject rdf:type <http://codyburleson.com/hyperg#Organization> .
    ?subject rdfs:label ?label
} LIMIT 100

Find all subjects with a given object property

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bc: <http://www.base22.com/ontologies/2010/5/bc.owl#>

SELECT ?subject
WHERE { ?subject bc:hasEmployer <http://www.base22.com/ontologies/2010/5/my-contacts.owl#IBM> } LIMIT 100

From my contacts ontology, I find all IBMers (i.e. the hasEmployer predicate points to the individual IBM, which is an object of type Organization).

Find all classes

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
 
SELECT DISTINCT ?type
WHERE {
  ?s a ?type.
}

The SPARQL keyword a is a shortcut for the common predicate rdf:type, giving the class of a resource.

Find all classes with a given prefix

PREFIX bc: <http://base22.com/ont/bc#>
 
SELECT DISTINCT ?type
WHERE {
  ?subject a ?type.
  FILTER( STRSTARTS(STR(?type),str(bc:)) )
}

The SPARQL keyword a is a shortcut for the common predicate rdf:type, giving the class of a resource.

Query from a particular graph on the web

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX card: <http://www.w3.org/People/Berners-Lee/card#>

SELECT ?homepage
FROM <http://www.w3.org/People/Berners-Lee/card>
WHERE {
 card:i foaf:knows ?known .
 ?known foaf:homepage ?homepage .
}

The FROM keyword lets us specify the target graph in the query itself.
Of interest also in the query shown above:
By using ?known as an object of one triple and the subject of another, we traverse multiple links in the graph.

Find subjects with a property value greater than

Find me all landlocked countries with a population greater than 15 million

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX type: <http://dbpedia.org/class/yago/>
PREFIX prop: <http://dbpedia.org/property/>

SELECT ?country_name ?population
WHERE {
 ?country a type:LandlockedCountries ;
 rdfs:label ?country_name ;
 prop:populationEstimate ?population .
 FILTER (?population > 15000000) .
}

You can try this one at the DBPedia SPARQL endpoint.

  • FILTER constraints use boolean conditions to filter out unwanted query results.
  • Shortcut: a semicolon (;) can be used to separate two triple patterns that share the same subject. (?country is the shared subject above.)
  • rdfs:label is a common predicate for giving a human-friendly label to a resource.

This page provides a log of how I setup a Liferay development environment using Ubuntu and VMWare Fusion. The idea is to be able to develop for Liferay CE and Liferay DXP although only the CE portion is fully setup so far, with the DXP portion standing by for potential completion in the case of a customer project. I like to snapshot my VMs frequently so that I can roll back at any point, so you will see indicators everywhere that I’ve taken a snapshot.

This also includes an acid-test, which is itself a mini-tutorial on how to create a RESTful web service endpoint in Liferay.

Continue Reading…

How to install Oracle Java 8 on Ubuntu (in may case, Ubuntu 16.04 LTS)

Procedure to install Oracle Java 8 on Ubuntu

You probably want to confirm first that a version of Java is not already installed. If so, you can do that with the java -version command as shown below…

developer@ubuntu:~$ java -version
The program 'java' can be found in the following packages:
 * default-jre
 * gcj-5-jre-headless
 * openjdk-8-jre-headless
 * gcj-4.8-jre-headless
 * gcj-4.9-jre-headless
 * openjdk-9-jre-headless
Try: sudo apt install <selected package>
developer@ubuntu:~$

Change to root…

sudo su -
(enter password)
apt-get install software-properties-common
add-apt-repository ppa:webupd8team/java
apt-get update
apt-get install oracle-java8-installer

Check if Java is successfully installed

java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

Procedure to uninstall

If, for some reason, you want to undo this operation and uninstall Oracle Java 8 from Ubuntu, you can then execute the following:

sudo su -
sudo apt-get remove oracle-java8-installer

 

Docker cheat sheet

A cheat sheet of commonly used docker commands.

List all containers

docker ps --all or docker ps -a

Remove all containers and images

Here are the two Docker commands you can run in sequence to completely remove (delete) all of your containers and images.

To remove all containers:

docker rm $(docker ps -a -q)

To remove all images:

docker rmi $(docker images -q)

Warning: Executing the commands shown above will destroy all your containers and images; it will not be possible to restore them.

List images

docker images

Remove an image

docker rmi <image-id>

Warning: Executing the commands shown above will destroy the given image; it will not be possible to restore it.

Container shell access

The docker exec command allows you to run commands inside a Docker container. The following command line will give you a bash shell inside your container:

docker exec -it <container-name> bash

If the container does not have bash installed you can use the following as an alternative:

docker exec -it <container-name> sh

Type exit to exit out of the container and return to your host shell.

List ports

The port command can be used to display the ports that are exposed by a given container.

docker port <container-name>

List processes

To see the processes running in a container, you can use the top command (similar to running the Linux top command):

docker top <container-name>

View container log file

docker logs <container-name>

RDF syntax examples

RDF can be expressed in a variety of different serialization formats. It can also be used inline with HTML. Following is an example of the most widely used of these formats so that you can compare them at a glance.

RDF/XML

An XML-based syntax for RDF graphs that was the first standard format for serializing RDF.

<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:gr="http://purl.org/goodrelations/v1#">
  <gr:Location rdf:about="http://www.acme.com/#store">
    <gr:name>Hepp's Happy Burger Restaurant</gr:name>
    <gr:hasOpeningHoursSpecification>
      <gr:OpeningHoursSpecification>
        <gr:opens>08:00:00</gr:opens>
        <gr:closes>20:00:00</gr:closes>
        <gr:hasOpeningHoursDayOfWeek rdf:resource="http://purl.org/goodrelations/v1#Wednesday"/>
        <gr:hasOpeningHoursDayOfWeek rdf:resource="http://purl.org/goodrelations/v1#Monday"/>
        <gr:hasOpeningHoursDayOfWeek rdf:resource="http://purl.org/goodrelations/v1#Tuesday"/>
        <gr:hasOpeningHoursDayOfWeek rdf:resource="http://purl.org/goodrelations/v1#Thursday"/>
        <gr:hasOpeningHoursDayOfWeek rdf:resource="http://purl.org/goodrelations/v1#Friday"/>
      </gr:OpeningHoursSpecification>
    </gr:hasOpeningHoursSpecification>
  </gr:Location>
</rdf:RDF>

See also: RDF 1.1 XML Syntax

Turtle

A compact, human-friendly format.

@prefix gr: <http://purl.org/goodrelations/v1#> .
 
<http://www.acme.com/#store>
  a gr:Location ;
  gr:name "Hepp's Happy Burger Restaurant" ;
  gr:hasOpeningHoursSpecification [
    a gr:OpeningHoursSpecification ;
    gr:opens "08:00:00" ;
    gr:closes "20:00:00" ;
    gr:hasOpeningHoursDayOfWeek gr:Wednesday, gr:Monday, gr:Tuesday, gr:Thursday, gr:Friday
  ] .

See also: Turtle – Terse RDF Triple Language

N-Triples

A very simple, easy-to-parse, line-based format that is not as compact as Turtle.

<http://www.acme.com/#store> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://purl.org/goodrelations/v1#Location> .
<http://www.acme.com/#store> <http://purl.org/goodrelations/v1#hasOpeningHoursSpecification> _:b0 .
<http://www.acme.com/#store> <http://purl.org/goodrelations/v1#name> "Hepp's Happy Burger Restaurant" .
_:b0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://purl.org/goodrelations/v1#OpeningHoursSpecification> .
_:b0 <http://purl.org/goodrelations/v1#opens> "08:00:00" .
_:b0 <http://purl.org/goodrelations/v1#closes> "20:00:00" .
_:b0 <http://purl.org/goodrelations/v1#hasOpeningHoursDayOfWeek> <http://purl.org/goodrelations/v1#Wednesday> .
_:b0 <http://purl.org/goodrelations/v1#hasOpeningHoursDayOfWeek> <http://purl.org/goodrelations/v1#Thursday> .
_:b0 <http://purl.org/goodrelations/v1#hasOpeningHoursDayOfWeek> <http://purl.org/goodrelations/v1#Friday> .
_:b0 <http://purl.org/goodrelations/v1#hasOpeningHoursDayOfWeek> <http://purl.org/goodrelations/v1#Tuesday> .
_:b0 <http://purl.org/goodrelations/v1#hasOpeningHoursDayOfWeek> <http://purl.org/goodrelations/v1#Monday> .

See also: RDF 1.1 N-Triples

N3 (or Notation3)

A non-standard serialization that is very similar to Turtle, but has some additional features, such as the ability to define inference rules.

@prefix gr: <http://purl.org/goodrelations/v1#> .
 
<http://www.acme.com/#store> a gr:Location;
    gr:hasOpeningHoursSpecification [ a gr:OpeningHoursSpecification;
            gr:opens "08:00:00";
            gr:closes "20:00:00";
            gr:hasOpeningHoursDayOfWeek gr:Friday,
                gr:Monday,
                gr:Thursday,
                gr:Tuesday,
                gr:Wednesday ];
    gr:name "Hepp's Happy Burger Restaurant" .

See also: Notation3 (N3): A readable RDF syntax

JSON-LD

a JSON-based serialization (for Linked Data).

{
  "@context": {
    "gr": "http://purl.org/goodrelations/v1#"
  },
  "@id": "http://www.acme.com/#store",
  "@type": "gr:Location",
  "gr:hasOpeningHoursSpecification": {
    "@type": "gr:OpeningHoursSpecification",
    "gr:closes": "20:00:00",
    "gr:hasOpeningHoursDayOfWeek": [
      {
        "@id": "gr:Thursday"
      },
      {
        "@id": "gr:Wednesday"
      },
      {
        "@id": "gr:Friday"
      },
      {
        "@id": "gr:Monday"
      },
      {
        "@id": "gr:Tuesday"
      }
    ],
    "gr:opens": "08:00:00"
  },
  "gr:name": "Hepp's Happy Burger Restaurant"
}

See also: JSON-LD 1.0

RDFa

Not really an RDF syntax, but rather – a compatible format. “RDFa is an extension to HTML5 that helps you markup things like People, Places, Events, Recipes and Reviews. Search Engines and Web Services use this markup to generate better search listings and give you better visibility on the Web, so that people can find your website more easily.” – rdfa.info

<div xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
     xmlns="http://www.w3.org/1999/xhtml"
     xmlns:gr="http://purl.org/goodrelations/v1#">
   <div about="http://www.acme.com/#store" typeof="gr:Location">
      <div rel="gr:hasOpeningHoursSpecification">
         <div typeof="gr:OpeningHoursSpecification">
            <div property="gr:closes" content="20:00:00"/>
            <div rel="gr:hasOpeningHoursDayOfWeek"
                 resource="http://purl.org/goodrelations/v1#Thursday"/>
            <div rel="gr:hasOpeningHoursDayOfWeek"
                 resource="http://purl.org/goodrelations/v1#Tuesday"/>
            <div rel="gr:hasOpeningHoursDayOfWeek"
                 resource="http://purl.org/goodrelations/v1#Monday"/>
            <div rel="gr:hasOpeningHoursDayOfWeek"
                 resource="http://purl.org/goodrelations/v1#Friday"/>
            <div rel="gr:hasOpeningHoursDayOfWeek"
                 resource="http://purl.org/goodrelations/v1#Wednesday"/>
            <div property="gr:opens" content="08:00:00"/>
         </div>
      </div>
      <div property="gr:name" content="Hepp's Happy Burger Restaurant"/>
   </div>
</div>

See also: RDFa

Microdata

Also not really an RDF syntax, but a compatible format. This mechanism allows machine-readable data to be embedded in HTML documents in an easy-to-write manner, with an unambiguous parsing model.

<div itemscope itemtype="http://purl.org/goodrelations/v1#Location" itemid="http://www.acme.com/#store">
  <span itemprop="name">Hepp's Happy Burger Restaurant</span>
  <div itemprop="hasOpeningHoursSpecification" itemscope
       itemtype="http://purl.org/goodrelations/v1#OpeningHoursSpecification">
Opening hours: Mo-Fri,
     <link itemprop="hasOpeningHoursDayOfWeek"
           href="http://purl.org/goodrelations/v1#Monday" />
     <link itemprop="hasOpeningHoursDayOfWeek"
           href="http://purl.org/goodrelations/v1#Tuesday" />
     <link itemprop="hasOpeningHoursDayOfWeek"
           href="http://purl.org/goodrelations/v1#Wednesday" />
     <link itemprop="hasOpeningHoursDayOfWeek"
           href="http://purl.org/goodrelations/v1#Thursday" />
     <link itemprop="hasOpeningHoursDayOfWeek"
           href="http://purl.org/goodrelations/v1#Friday" />
     <meta itemprop="opens" content="08:00:00">8:00 a.m. -
     <meta itemprop="closes" content="20:00:00">8:00 p.m.
  </div>
</div>

See also: HTML Microdata

RDF Converter Services Online

There’s a few decent RDF converter services that you can use online:

SPARQL examples – filter

Return items with recorded date less than given date

PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX web: <http://base22.com/ont/web#>
 
SELECT * WHERE {
    ?subject dcterms:title ?title.
    ?subject dcterms:abstract ?abstract.
    ?subject web:publishDate ?publishDate.
    FILTER (?publishDate < "2016-09-28T19:19:02.982Z"^^xsd:dateTime)
}