This guide details the steps to set up a local Aerospike Database instance using Docker. It specifically addresses common connectivity issues on Windows/WSL2 environments.
- Docker Desktop (Windows/Mac) or Docker Engine (Linux) installed.
- Java JDK 8+ (for the client application).
- Maven (for dependency management).
If you encounter the error:
docker: error during connect: Head "http://%2F%2F.%2Fpipe%2FdockerDesktopLinuxEngine/_ping": open //./pipe/dockerDesktopLinuxEngine: The system cannot find the file specified.
Follow these steps to fix it:
- Launch Docker Desktop: Press the
Windows Key, type "Docker Desktop", and open the application. - Wait for Initialization: Look at the system tray (bottom right). Wait until the Docker "whale" icon stops animating and remains steady.
- Verify via Terminal: Open your terminal (Command Prompt or PowerShell) and run:
Success Output: You should see details for both
docker version
Client:andServer:.
Once Docker is active, run the following command to download and start the Aerospike Community Edition server.
docker run -d --name aerospike -p 3000:3000 -p 3001:3001 -p 3002:3002 aerospike/aerospike-serverVerify it is running:
docker psThis section details how to build the Spring Boot application, run it locally, and test the APIs using cURL commands.
This command downloads all necessary dependencies and compiles your code into an executable artifact.
mvn clean installNote: If the build fails due to connection issues during testing, ensure your Docker container is running. You can also skip tests by adding -DskipTests to the command.
Step 2: Run the Application The fastest way to run the app during development (avoiding the need to package a JAR every time) is using the Spring Boot Maven plugin:
Option 1 : Bash
mvn spring-boot:run "-Dspring-boot.run.jvmArguments=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"
Option 2 : Bash
mvn spring-boot:run
Success Indicator: Look for logs ending with Started AerospikeApplication in X seconds and confirmation that the server is listening on port 8080.
Use the following commands to interact with your running application via the terminal.
For Windows (Command Prompt / PowerShell): Note: Windows requires double quotes for JSON and escaped internal quotes ".
curl -X POST http://localhost:8080/api/users ^
-H "Content-Type: application/json" ^
-d "{\"id\": \"user_500\", \"name\": \"Curl Master\", \"email\": \"curl@test.com\", \"experience\": 10}"
For All Platforms:
curl http://localhost:8080/api/users/user_500
You attempt to spin up a new Aerospike container using docker run, but the command fails with a naming conflict error.
Command Run:
docker run -d --name aerospike -p 3000:3000 -p 3001:3001 -p 3002:3002 aerospike/aerospike-serverError Received:
docker: Error response from daemon: Conflict. The container name "/aerospike" is already in use by container "abcd...". You have to remove (or rename) that container to be able to reuse that name.
Root Cause
Docker containers have a lifecycle. Even when a container is stopped (and disappears from docker ps), it still exists on disk in an "Exited" state.
Docker prevents you from creating a new container with the name aerospike because a stopped container with that name already exists.
Solutions
Use this if: You want a clean slate, or you are unsure if the old container had the correct port mappings. This deletes the old container and creates a brand new one.
Remove the old container:
docker rm aerospike
Run the new container:
docker run -d --name aerospike -p 3000:3000 -p 3001:3001 -p 3002:3002 aerospike/aerospike-server
Use this if: The old container was working fine previously, and you just want to resume it (preserving any data stored inside it).
Start the existing container:
docker start aerospike
Verification
After applying one of the fixes above, verify the database is running and accessible.
Check Process Status:
docker ps
Look for: aerospike in the NAMES column.
Look for: Up X seconds in the STATUS column.
You have two ways to run the app. Choose Option A if you need to debug.
Follow these steps to attach the debugger and inspect your code line-by-line.
- Open the Project: Launch IntelliJ IDEA and ensure your Maven project is loaded.
- Open Main Class: Navigate to your main application file (e.g.,
AerospikeDemoApplication.java). - Launch Debug Mode: Right-click anywhere in the code editor window and select Debug 'AerospikeDemoApplication'.
- Look for the green bug icon.
- Set Breakpoints: Click the gutter (the gray space to the left of the line numbers) next to the line of code you want to stop at.
- A red dot will appear indicating the breakpoint is active.
- Trigger the Logic: Send a request to your application using Postman, cURL, or a browser.
- Debug: The IDE will automatically pause execution when it hits your breakpoint, allowing you to inspect variables and step through the code.