This image provides a ready-to-run container for the H2 database.
182
This image provides a ready-to-run container for the H2 database. The image is based on a lightweight JRE and is configured with specific command-line options to run H2 in TCP mode together with a web console.
This container sets up the H2 Database Engine, providing:
Create a docker-compose.yml file with the following content. These settings enable tracing, expose a web console, start a TCP server, and specify that all database files are stored under /h2/data:
version: '3.8'
services:
h2-database-engine:
image: docker.io/eduardoenemark/h2-database-engine:1.0
container_name: h2-database-engine
restart: always
ports:
- "0.0.0.0:9092:9092/tcp"
- "0.0.0.0:8082:8082/tcp"
volumes:
- ./h2-data:/h2/data
command: [ "-trace", "-web", "-tcp", "-ifNotExists", "-webAllowOthers", "-tcpAllowOthers", "-baseDir", "/h2/data" ]
deploy:
resources:
limits:
cpus: 1
memory: 512m
./h2-data:/h2/data stores all H2 database files on the host, ensuring persistence across container restarts.[Note] This is an example configuration that demonstrates how to run the H2 database engine in a container. You should customize the image name, tag, and volume paths according to your specific requirements. The volume mapping ./h2-data:/h2/data stores all database files on the host, so they remain available after container restarts.
[Note] Default options: -trace -web -tcp -baseDir /h2/data/.
All database files are written to /h2/data inside the container; because this directory is mounted to ./h2-data on the host, the data survive container restarts and can be backed up simply by copying that host folder.
JDBC URL example
jdbc:h2:tcp://localhost:9092/h2/data/<db-name>;MODE=<db-vendor>
Replace <db-name> with your database identifier, and replace <db-vendor>. This format is useful for applications that use JDBC drivers.
The web console can be accessed at:
http://localhost:8082
No user or password is configured in the example; you may adjust security settings as needed.
docker-compose up
podman run -it --rm \
--name h2-database-engine \
-p 9092:9092/tcp \
-p 8082:8082/tcp \
-v $(pwd)/h2-data:/h2/data \
docker.io/eduardoenemark/h2-database-engine:1.0 \
-trace -web -tcp -ifNotExists -webAllowOthers -tcpAllowOthers -baseDir /h2/data
This project is licensed under GPL-3.0.
Content type
Image
Digest
sha256:946a97ff6…
Size
121.7 MB
Last updated
7 months ago
docker pull eduardoenemark/h2-database-engine:1.0