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

Create a database at startup #142

Closed
fungiboletus opened this issue Mar 13, 2019 · 3 comments
Closed

Create a database at startup #142

fungiboletus opened this issue Mar 13, 2019 · 3 comments

Comments

@fungiboletus
Copy link

The documentation says

Please note that CouchDB no longer autocreates system databases for you, as it is not known at startup time if this is a single-node or clustered CouchDB installation.

Could it be possible to add back the possibility to autocreate the database when the container is not used in a cluster ? It could be a simple if on an optional environment variable.

@wohali
Copy link
Member

wohali commented Mar 13, 2019

This would be better served as a CouchDB enhancement, not a Docker enhancement. Moving the issue.

@happilymarrieddad
Copy link

@fungiboletus @wohali

#148

@florianb
Copy link

florianb commented Nov 28, 2019

For all restless souls having the same problem, we just redefined the dockerfile CMD:

docker run couchdb:latest sh -c "/opt/couchdb/bin/couchdb & { sleep 3 ; curl -X PUT http://127.0.0.1:5986/_users ; curl -X PUT http://127.0.0.1:5986/_replicator ; curl -X PUT http://127.0.0.1:5986/_global_changes ; fg ; }"

& puts CouchDb in the background and runs subsequent commands in the foreground, {} couples the inner commands without invoking a subshell, ; runs the commands sequentially, sleep 3 waits 3 seconds (to let relax a bit), curlcreates the missing database and fg pulls the CouchDb job to the foreground again.

🛋️


Our original .gitlab-ci.yml-service:

services:
  - name: couchdb:latest
    command: ["sh", "-c", "/opt/couchdb/bin/couchdb & { sleep 3 ; curl -X PUT http://127.0.0.1:5986/_users ; curl -X PUT http://127.0.0.1:5986/_replicator ; curl -X PUT http://127.0.0.1:5986/_global_changes ; fg ; }"]

Edit: it seems like port 5986 will be dropped in near future - however, it was the only port working in our container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants