The new Docker images (built as of May 19th 2021) will include a script /usr/local/tomcat/db.sh
that connects you to the configured database with the appropriate native database client (mysql
for a MySQL database, psql
for a PostgreSQL database, sqlplus
for Oracle, etc.)
For instance, let’s say you have started a database and a Simplicité container with :
[sudo] docker-compose up [-d]
Using a docker-compose.yml
configuration file like this one.
You can connect to the database with the following command:
[sudo] docker-compose exec simplicite ./db.sh
(or, at a lower level, with [sudo] docker exec -it <your Simplicité container name or ID> ./db.sh
)
Usage examples:
With MySQL (e.g. with this config file)
With PostgreSQL (e.g. with this config file):
With HSQLDB (e.g. with this config file):
WARNING: The above exec
method does not apply if you are using an embedded HSQLDB database instead of an external database, because you can’t connect to the database whilst it is used by Tomcat (such an embedded database can only be used by a single process). In this case you must stop the container by a docker-compose down
and then run an ephemeral container with :
[sudo] docker-compose run --rm simplicite ./db.sh