Apache Solr
What is Apache Solr?
Apache Solr is a search platform built on Apache Lucene, offering full-text search, faceting, and indexing over HTTP. Laradock builds it from the official solr Docker image, with its admin UI and API on one port.
Start Solr
- Laradock CLI
- Docker Compose
./laradock start solr
docker compose up -d solr
Name any other services alongside it to start them together, for example ./laradock start solr mysql.
Stop Solr
Stopping just pauses the container; your cores are safe, they live under DATA_PATH_HOST/solr:
- Laradock CLI
- Docker Compose
./laradock stop solr
docker compose stop solr
To delete the container entirely (the data on disk is still untouched):
- Laradock CLI
- Docker Compose
./laradock remove solr
docker compose rm -sf solr
Configuration
All settings live in solr/defaults.env and can be overridden by adding the same line to your own .env:
| Variable | Default | What it does |
|---|---|---|
SOLR_VERSION | 8.11 | Image tag from the official Solr image. |
SOLR_PORT | 8983 | Host-side port for both the admin UI and the API (container port 8983). |
SOLR_DATAIMPORTHANDLER_MYSQL | false | When true, downloads the MySQL Connector/J JDBC driver at build time for the DataImportHandler. |
SOLR_DATAIMPORTHANDLER_MSSQL | false | When true, downloads the Microsoft JDBC driver at build time for the DataImportHandler. |
Open the admin UI
http://localhost:8983/solr
Create a core
- Laradock CLI
- Docker Compose
./laradock exec solr solr create_core -c mycore
docker compose exec solr solr create_core -c mycore
Check core status
- Laradock CLI
- Docker Compose
./laradock exec solr solr status
docker compose exec solr solr status
You can also check a single core's health from the admin UI (Core Admin page) or by hitting http://localhost:8983/solr/mycore/admin/ping.
Delete a core
- Laradock CLI
- Docker Compose
./laradock exec solr solr delete -c mycore
docker compose exec solr solr delete -c mycore
Enable a JDBC data import connector
- In
.env, setSOLR_DATAIMPORTHANDLER_MYSQL=true(orSOLR_DATAIMPORTHANDLER_MSSQL=true). - Rebuild with a clean cache, since the connector is downloaded during the build:
docker compose build --no-cache solr
Backup and restore a core
Solr's replication handler can snapshot a core to disk and restore it later, no extra tooling needed. Both commands hit the core's own HTTP endpoint:
Back up mycore (writes a snapshot.<timestamp> folder inside that core's data directory, under DATA_PATH_HOST/solr/mycore/data):
curl "http://localhost:8983/solr/mycore/replication?command=backup"
Check command=details to confirm the backup finished before relying on it:
curl "http://localhost:8983/solr/mycore/replication?command=details"
Restore the most recent snapshot back into mycore:
curl "http://localhost:8983/solr/mycore/replication?command=restore"
Both commands run asynchronously; poll restore progress with command=restorestatus. Because the snapshot is written under DATA_PATH_HOST/solr, copying that folder off-host is also a valid manual backup.
Start completely fresh (wipe all data)
To throw away every core and start Solr from a clean, empty state (⚠️ this permanently deletes all cores and their indexed data, back up first if you need anything):
- Laradock CLI
- Docker Compose
./laradock stop solr
./laradock remove solr
rm -rf "${DATA_PATH_HOST:-~/.laradock/data}/solr"
./laradock start solr
docker compose stop solr
docker compose rm -sf solr
rm -rf "${DATA_PATH_HOST:-~/.laradock/data}/solr"
docker compose up -d solr
DATA_PATH_HOST is whatever you have set in .env (~/.laradock/data by default). That folder is mounted straight to /opt/solr/server/solr/mycores, Solr's entire cores directory, so wiping it removes every core, not just their documents. After starting again you'll need to create your cores from scratch.
Tune the JVM heap size
Solr's upstream image reads its JVM heap size from a SOLR_HEAP environment variable, but solr/compose.yml doesn't pass it through by default. Add it yourself under the solr service:
environment:
- SOLR_HEAP=1g
Then apply the change:
- Laradock CLI
- Docker Compose
./laradock restart solr
docker compose restart solr
Solr's default heap is fairly small (512m); indexing anything non-trivial usually calls for raising this.
Talk to this Solr from another Laradock project
Each Laradock project is its own isolated Docker network by default, so a second project's containers can't reach this Solr by container name out of the box. Easiest fix: publish the port (already done, SOLR_PORT) and have the other project connect to your host machine's address instead of solr, for example http://host.docker.internal:8983/solr (Docker Desktop). Make sure the two projects use different SOLR_PORT values if they're both running at once.
Common issues
- Changing
SOLR_VERSIONdoesn't take effect. It's a build argument, rebuild after changing it:./laradock rebuild solr. - JDBC connectors missing. They're only fetched when the matching flag was
trueat build time, flip the flag and rebuild withdocker compose build --no-cache solr, a plain rebuild reuses the cached layer and skips the download. - Cores don't persist across restarts. They're written to
DATA_PATH_HOST/solr(mounted to/opt/solr/server/solr/mycores), confirmDATA_PATH_HOSTis set consistently between runs. - Port already in use on your host. Change
SOLR_PORTin.envand restart:./laradock restart solr. - Indexing is slow or Solr gets OOM-killed on large collections. Raise the JVM heap, see Tune the JVM heap size above.
Need a lighter-weight search engine instead? See Manticore. Back to the Getting Started guide.