H2 database docker container with Web UI.
You should put the database files on a volume on you host system or in a container based data volume.
The following shows how to run the H2 database on files to be persisted in host computers file system.
Annoying thing is that the windows filesystem may not get mounted as a volume when the virtual machine is used (as it is often when you use Docker Toolbox). As a workaround: mount a directory from user directory or add the directory you want to use as a volume to your virtual machine (like the user directory by default is).
Run docker container:
docker run -d -p 1521:1521 -p 81:81 -v /c/Users/joedo/dockermount:/data --name=h2db joedoe/h2db
1521: TCP/IP port the database may get accessed from, to be used in JDBC connection string
81: web port for the H2 web based user interface
v: mapping a shared host file system directory to be accessible from container, in this case the dircetory
/c/Users/joedo/dockermountfrom the Windows host system is mounted to directory
/datainside the container
Accessing With Web UI
Point your browser to
192.168.99.100 being the IP of your local docker machine, maybe needs to be adjusted to you local settings)
Open and thereby create an empty database by using the following JDB URL:
- username and password will be
sa(= system administrator) by default
- observe the filename to persist the database to is part of the URL and accessible in file system:
Accessing With JDBC
Use the following JDBC URL to access a database (`@docker.hostname@
to be replaced by your local docker machine IP, e.g.192.168.99.100`):