So, I am setting up Zookeeper in my local environment on docker using the official docker image. Now, what I want with this Zookeeper setup is to be able to persist the nodes and their values by mounting the Zookeeper data directory as a volume inside my container.
This is straightforward, but what's confusing me is that Zookeeper's data directory inside the container is at /data
while the datalog directory is at /datalog
. Ideally, I would expect Zookeeper to persist the nodes and values inside the data folder as well in addition to the datalog directory. However, I find that while the datalog directory has the data in log.*
files, the data directory does not have any data related to the test nodes that I created.
bash-4.4# pwd
/datalog/version-2
bash-4.4# ls
log.1 log.3 log.5 log.8
bash-4.4# pwd
/data/version-2
bash-4.4# ls
bash-4.4#
My goal is achieved with this Zookeeper service in my docker-compose.yml
-
volumes:
- zkdata:/datalog
but this seems counter-intuitive that I am mounting the transaction logs directory instead of the actual data directory. How and where does Zookeeper actually persist the node data and how can I correctly mount it as a volume in my docker container?
I can actually set the ZOO_DATA_LOG_DIR
environmental variable to /data
and mount that as a docker volume, but my question is really about why the Zookeeper data is empty while the datalog directory isn't.