Fast-starting database containers optimized for testing.
This repository contains Docker containers for databases that are optimized for fast startup in test environments. The key optimization is pre-initializing expensive setup operations during the Docker image build phase, so containers start almost instantly at runtime.
A PostgreSQL container with pre-initialized data directory.
Optimization: The data cluster is created during the Docker build, so at runtime PostgreSQL just starts the server without any initialization.
Startup time: ~1 second (vs 3-5 seconds for standard container)
Connection: postgresql://postgres:postgres@localhost:5432/postgres
A TigerBeetle container with pre-formatted data file.
Optimizations:
- The data file (~1GB) is formatted during a one-time setup step, then baked into the image.
- Uses
--developmentmode for minimal memory footprint (~1.4GB vs ~2.3GB). - Uses
tinias the init process sodocker stoptakes ~0.3s instead of the default 10s timeout (the upstream binary ignores signals when running as PID 1).
Startup time: ~1 second
Shutdown time: ~0.3 seconds
Connection: Port 3000, Cluster 1
Required runtime flags: --security-opt seccomp=unconfined (TigerBeetle uses io_uring, which Docker blocks by default).
A Keycloak container with pre-initialized H2 database.
Optimization: The H2 database is initialized during the Docker build, so at runtime Keycloak just starts the server without any initialization.
Startup time: ~2 seconds (vs ~30 seconds for standard container)
Connection: Port 8080, Realm master, User admin, Password admin
All containers follow the same optimization pattern:
-
Two-phase initialization:
- Phase 1 (Build time): Expensive setup is done once during image build
- Phase 2 (Runtime): Only the server starts, no initialization overhead
-
Benefits:
- Faster test suite execution
- Consistent initial state for each test
- No volume mounts needed for basic tests
- Isolated, ephemeral data perfect for testing
See examples/go/tigerbeetle_test.go for a working example that starts multiple TigerBeetle instances in parallel using testcontainers-go.
Key points when using this image programmatically:
- Always set
--security-opt seccomp=unconfinedin the host config. - Wait for the log
"listening on"rather than just an open port, because TigerBeetle opens the port before it is fully ready. - Terminate containers normally; because the image uses
tini, shutdown is instant.