#1
Apache Derby, often called JavaDB, is a lightweight, embeddable relational database written entirely in Java. Combined with Docker, it becomes super easy to spin up for development without much setup. In this guide, let's explore how to get Derby running in a Docker container, how to persist your data, and how to connect to it—all in a developer-friendly way.

1. Choose a Derby Docker Image

There are a few Docker images for Derby available. A popular one is az82/docker-derby, built on a slim Eclipse Temurin JRE, It comes with:
  • Derby version 10.16+
  • Derby Network Server listening on port 1527
  • A /dbs volume to store database files
  • Health check support
To pull it:
docker pull az82/docker-derby:latest

2. Run Derby with Docker

Here's a quick command to get Derby up and running:
docker run -d \
  --name derby-dev \
  -p 1527:1527 \
  -v ~/derby-dbs:/dbs \
  az82/docker-derby
  • -p 1527:1527 exposes Derby's default client port
  • -v ~/derby-dbs:/dbs persists databases across container restarts

3. Connect to Derby

Derby lets you connect in two modes:
  • Network Client – via JDBC (jdbc:derby://localhost:1527/yourdb;create=true)
  • Embedded – directly in your Java app
For the network server model, your JDBC URL in Java might look like:
String url = "jdbc:derby://localhost:1527/mydb;create=true";
DriverManager.getConnection(url);

4. Use Docker Compose for Convenience

A docker-compose.yml makes it easy to share setup with teammates:
version: '3'
services:
  derby:
    image: az82/docker-derby
    container_name: derby-dev
    ports:
      - "1527:1527"
    volumes:
      - ./dbs:/dbs
Launch it via:
docker-compose up -d

5. Verify the Server

You can verify Derby is running using any SQL client:
SELECT * FROM SYS.SYSSERVERS;
Or check container logs:
docker logs derby-dev

6. Persist and Share Your Database

By mounting a volume to /dbs, your Derby data lives on your host machine. To share:
  • Include the ./dbs folder in version control
  • Or follow your team's data-sharing practices
  • Copy .db files between environments when collaborating

7. Stop and Remove the Container

When you're done:
docker stop derby-dev
docker rm derby-dev
Your data remains safe in ~/derby-dbs.

Why Docker Makes Derby Easier

  • No manual install – no need for API downloads or environment setup
  • Quick spin-up – have a database ready in seconds
  • Easy cleaning – consistent environment with minimal effort
  • Data persistence – volumes ensure your data survives
  • Lightweight – great for test servers or development environments
With a few Docker commands (or a Docker Compose setup), you're ready to develop using Derby as your relational database. It's perfect for lightweight testing, prototyping, or local development environments. No heavyweight installations, just quick and clean database access so you can focus on writing code

image quote pre code