Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFE: Put SQLite DB into a directory, so it can be hosted on docker volume (so it survives an image upgrade) #409

PAStheLoD opened this issue Jul 4, 2018 · 4 comments


Copy link

@PAStheLoD PAStheLoD commented Jul 4, 2018

General information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): docker 17.12.0-ce on CentOS 7
  • ElasticHQ Version: v3.4.0 (current latest, 9f821357c54a)
  • Elasticsearch Version: N/A
  • Python version: N/A
  • Browser Vendor and Version (if applicable): N/A

Issue Description

Currently recreating a docker container containing an elastichq.db results in the loss of that file, and without an ugly workaround it's hard to relocate that file.

Source Code / Logs

The location of elastichq.db is hardcoded into ProdSettings:

Probable drawbacks

Of course, maybe this might require SQL Alchemy migrations.

Copy link

@royrusso royrusso commented Jul 5, 2018

This may be possible using an external settings.json.... this needs to be documented but is already supported. I have an open issue for this, and will update this when I've tested it. #407

@royrusso royrusso added this to the 3.4.1 milestone Jul 5, 2018
Copy link

@PAStheLoD PAStheLoD commented Jul 5, 2018

That'd require mounting and maintaining an external settings file.

I currently use this "one liner" to put the DB file into a directory. ("db" already exists, it's just empty for some reason.)

docker run --detach \
           --restart=always \
           --net host \
           --volume elastichq:/src/db \
           --name elastichq \
           elastichq/elasticsearch-hq \
           sh -x -c 'sed -i -r -e "s/_sqlalchemy_database_uri =.*/_sqlalchemy_database_uri = \"sqlite:\/\/\/\" + os.path.join(BASEPATH, \"db\" , \"elastichq.db\")/" /src/elastichq/config/ && exec supervisord -c /etc/supervisor/supervisord.conf'
Copy link

@royrusso royrusso commented Jul 13, 2018

That's a heck of a one-liner. I will add this to the docs as well.

Copy link

@wjwGeronimo wjwGeronimo commented Jan 22, 2020

docker run -d -p 5000:5000 --mount type=bind,source="$(pwd)"/elastichq.db,target=/src/elastichq.db elastichq/elasticsearch-hq:release-v3.5.12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants