Run Neo4j 5 in Docker, load a small graph, and practice Cypher patterns, paths, and aggregations.
Neo4j stores relationships as first-class citizens, which makes multi-hop questions natural. This lab starts Neo4j with the Browser, loads a small social graph, and walks through Cypher MATCH, MERGE, variable-length paths, and shortestPath.
docker compose up -d
docker compose cp examples/01_seed.cypher neo4j:/tmp/01_seed.cypher
docker compose cp examples/02_queries.cypher neo4j:/tmp/02_queries.cypher
docker compose exec neo4j cypher-shell -u neo4j -p labpassword -f /tmp/01_seed.cypher
docker compose exec neo4j cypher-shell -u neo4j -p labpassword -f /tmp/02_queries.cypher
open http://localhost:7474| Field | Value |
|---|---|
| Browser | http://localhost:7474 |
| Bolt | neo4j://localhost:7687 |
| User | neo4j |
| Password | labpassword |
| cypher-shell | docker compose exec neo4j cypher-shell -u neo4j -p labpassword |
| File | What it shows |
|---|---|
docker-compose.yml |
Engine, ports, and persistent volume. |
.github/workflows/compose-check.yml |
Validates the Compose file on every push. |
examples/01_seed.cypher |
A small graph of people, companies, and skills. |
examples/02_queries.cypher |
Pattern matching, aggregation, and shortest paths. |
- Add a
PROJECTrelationship between people and projects, then query two-hop neighbors. - Use
MERGEto make the seed script idempotent. - Create a full-text index on
Person.nameand query it. - Profile a query with
PROFILEand explain the number of db hits.
- The password
labpasswordis a local lab credential. Change it before exposing Bolt. - The Browser on port 7474 is the easiest way to explore the graph visually.
- Cypher is case-sensitive for labels and relationship types in this lab's examples.
- Data persists in the
neo4j-datavolume.
This lab publishes its ports on 127.0.0.1 only. To use it from another country, do not open the database port to the internet. Pick one:
- VPS + private tunnel: run the lab on a small Ubuntu VPS, keep the port closed, and connect through WireGuard or
ssh -L. - Managed service: use a managed free tier for this engine and point the same examples at its connection string.
- HTTP UI only: if the engine has a web UI, put it behind Caddy with TLS and basic auth.
The shared checklist, provider map, and commands are in REMOTE-ACCESS.md.
docker compose down -v-v also removes the named volume, so the next start is a clean slate.
Part of the database-labs collection: 26 database engines, one index.
MIT (c) 2026 Arya Fatthurahman. See LICENSE.