Aerospike
What is Aerospike?
Aerospike is a distributed, high-performance NoSQL key-value database built for low-latency reads and writes at scale, commonly used for real-time use cases like ad targeting, fraud detection, and session stores.
Start Aerospike
- Laradock CLI
- Docker Compose
./laradock start aerospike
docker compose up -d aerospike
Your data is created on first start and kept between restarts.
Stop Aerospike
Stopping just pauses the container; your data is safe:
- Laradock CLI
- Docker Compose
./laradock stop aerospike
docker compose stop aerospike
To delete the container entirely (the data on disk is still untouched, it lives under DATA_PATH_HOST):
- Laradock CLI
- Docker Compose
./laradock remove aerospike
docker compose rm -sf aerospike
Configuration
All settings live in aerospike/defaults.env and can be overridden by adding the same line to your own .env:
| Variable | Default | What it does |
|---|---|---|
AEROSPIKE_SERVICE_PORT | 3000 | Host-side port for the client service port. |
AEROSPIKE_FABRIC_PORT | 3001 | Host-side port for inter-node cluster communication. |
AEROSPIKE_HEARTBEAT_PORT | 3002 | Host-side port for cluster heartbeat messages. |
AEROSPIKE_INFO_PORT | 3003 | Host-side port for the info/monitoring protocol. |
AEROSPIKE_STORAGE_GB | 1 | Storage size (in GB) allocated to the container, passed in as STORAGE_GB. |
AEROSPIKE_MEM_GB | 1 | Memory limit (in GB) for the container, passed in as MEM_GB. |
AEROSPIKE_NAMESPACE | test | Default Aerospike namespace created on boot, passed in as NAMESPACE. |
Change namespace, storage, or memory limits
AEROSPIKE_NAMESPACE, AEROSPIKE_STORAGE_GB, and AEROSPIKE_MEM_GB are passed into the container as plain runtime environment variables (not baked in at build time), so a restart is enough to apply a change, no rebuild needed. Set the new value in .env, then:
- Laradock CLI
- Docker Compose
./laradock restart aerospike
docker compose restart aerospike
Changing AEROSPIKE_NAMESPACE doesn't rename or migrate data already stored under the old namespace, it just changes which namespace the server exposes on boot.
Change the Aerospike version
The version is pinned by the AEROSPIKE_VERSION build arg at the top of aerospike/Dockerfile (ce-8.1.2.2 by default), it isn't exposed as an .env variable. Edit that line to the tag you want from Aerospike's Docker Hub, then rebuild:
- Laradock CLI
- Docker Compose
./laradock rebuild aerospike
docker compose build aerospike
Connect from PHP
Aerospike needs its own PHP extension to talk to the server from php-fpm/workspace. That's a separate install step, see Install the Aerospike extension for the WORKSPACE_INSTALL_AEROSPIKE/PHP_FPM_INSTALL_AEROSPIKE flags and rebuild command.
Once installed, connect to the server by container name and service port:
$client = new Aerospike(["hosts" => [["addr" => "aerospike", "port" => 3000]]]);
Connect from your host machine
Inside Laradock, other containers reach it by container name: aerospike:3000. From your own machine, connect to localhost:3000 (or your custom AEROSPIKE_SERVICE_PORT) using the Aerospike CLI tools or a compatible client.
Check node status
Open a terminal inside the container, then ask the running node for its status:
- Laradock CLI
- Docker Compose
./laradock enter aerospike
asinfo -v status
docker compose exec aerospike bash
asinfo -v status
A healthy node replies ok. Run asinfo -v namespaces the same way to list the namespaces currently configured on the node.
Backup and restore
Aerospike's data lives entirely under the DATA_PATH_HOST/aerospike volume mount, so backing it up is a matter of stopping the node and copying that folder while nothing is writing to it.
Back up:
- Laradock CLI
- Docker Compose
./laradock stop aerospike
docker compose stop aerospike
cp -r "${DATA_PATH_HOST:-~/.laradock/data}/aerospike" ./aerospike-backup-$(date +%Y%m%d)
- Laradock CLI
- Docker Compose
./laradock start aerospike
docker compose up -d aerospike
Restore from a backup folder made the same way (⚠️ this replaces everything currently in DATA_PATH_HOST/aerospike):
- Laradock CLI
- Docker Compose
./laradock stop aerospike
docker compose stop aerospike
rm -rf "${DATA_PATH_HOST:-~/.laradock/data}/aerospike"
cp -r ./aerospike-backup-20260101 "${DATA_PATH_HOST:-~/.laradock/data}/aerospike"
- Laradock CLI
- Docker Compose
./laradock start aerospike
docker compose up -d aerospike
Start completely fresh (wipe all data)
To throw away everything and start Aerospike from a clean, empty state (⚠️ this permanently deletes all data in this container, back up first if you need anything):
- Laradock CLI
- Docker Compose
./laradock stop aerospike
./laradock remove aerospike
rm -rf "${DATA_PATH_HOST:-~/.laradock/data}/aerospike"
./laradock start aerospike
docker compose stop aerospike
docker compose rm -sf aerospike
rm -rf "${DATA_PATH_HOST:-~/.laradock/data}/aerospike"
docker compose up -d aerospike
DATA_PATH_HOST is whatever you have set in .env (~/.laradock/data by default), so the folder above is where Aerospike's data actually lives on your machine.
Talk to this 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 Aerospike by container name out of the box. Easiest fix: the service, fabric, heartbeat, and info ports are already published to your host, so have the other project connect to your host machine's address instead of aerospike, for example host.docker.internal (Docker Desktop) with the port set to this project's AEROSPIKE_SERVICE_PORT. Make sure the two projects use different values for all four Aerospike ports if they're both running at once.
Common issues
- Client can't connect at all. Aerospike needs all four ports (service, fabric, heartbeat, info) reachable for the node to run correctly, not just the service port. Confirm none of
AEROSPIKE_SERVICE_PORT/AEROSPIKE_FABRIC_PORT/AEROSPIKE_HEARTBEAT_PORT/AEROSPIKE_INFO_PORTcollide with something else on your host. - "Namespace not found" errors. Your client is targeting a namespace that doesn't match
AEROSPIKE_NAMESPACE(defaulttest). Either use that namespace or changeAEROSPIKE_NAMESPACEand./laradock restart aerospike. - PHP calls fail with "class Aerospike not found." The PHP extension isn't installed yet, it's not bundled by default. Follow Install the Aerospike extension and rebuild
workspace/php-fpm. - Out-of-memory or storage errors under real load.
AEROSPIKE_MEM_GB/AEROSPIKE_STORAGE_GBdefault to1, fine for local dev, but bump them in.envif you're testing with meaningful data volumes, then./laradock restart aerospike. - Node reports itself unhealthy after a host reboot. Run
./laradock logs aerospikeand check for storage errors before assuming data is lost, a node re-joining after an unclean shutdown can take a few seconds to come back tookinasinfo -v status.
New to Laradock? Start at Getting Started.