Our previous post (Running MonetDB in containers) described how to use the MonetDB images we publish at dockerhub. However, the process explained there is not very straightforward. Ideally, we would like to start the container and then be able to manage databases in it using the tools installed in the host machine.
To do this, we need to be able to set a few properties for the dbfarm, and in order to do that, the farm needs to be created not when the image is built, but when the container starts for the first time.
This process is implemented by changing the entrypoint of the image to be a script that will create the dbfarm, and set the needed properties. Then, you can pass these properties to the script as environment variables.
The possible properties you can specify are the following:
monetdb, but you should seriously consider changing it. You can change it by setting the environment variable
merovingian.logrelative to the database farm directory. You can change it by setting the environment variable
.tar.lz4, but other possible values are
.tar.bz2. You can change it by setting the environment variable
Finally, there is a special environment variable
if defined, displays all the properties associated with the database
farm in the container.
You can set the values of these parameters to the MonetDB daemon in the container by using the environment variable mechanism of the container runtime. For example, in docker you would say:
docker run --rm -p 50000:50000 -it -e MDB_SHOW_VARS=1 -e MDB_SNAPSHOTDIR=/snapshots -e MDB_SNAPSHOTCOMPRESSION=.tar -v snapshots:/snapshots -v data-vol:/var/monetdb5/ monetdb/monetdb:latest
This invocation mounts two local directories,
/tmp/farm as volumes in the container, mapped to
/var/monetdb5 respectively. It also sets the variables
MDB_SHOW_VARS. Notice that we mount a separate docker volume for the
snapshots and specify the value for
You should keep in mind that the database farm is always located at
/var/monetdb5/dbfarm inside the container, so you
should map your external volumes there.
Hopefully these changes will make it even easier to use containerized MonetDB.