Let's install Docker and set it to be from their repository instead of Ubuntu (which comes by default). Also, let's disable root mode in order to run Docker.
sudo apt install apt-transport-https ca-certificates curl software-properties-common && curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - && sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic test" && sudo apt update && sudo apt install docker-ce
To save money and not run each instance of CouchDB by servers,
let's create instances for each project.
And define and admin & password (since CouchDB doesn't)
Remove -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=password
if you want to start CouchDB as admin party default.
Now, let's install CouchDB
docker run -d --name mQserv couchdb
Or with more parameters:
docker run --name mQdb --restart=always -p 80:5984 --link mQserv:couch couchdb -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=password
(restart: always, listen on port 80 proxying default 5984 of couch)
Run:
docker run -p 5984:5984 -d couchdb
As you work with Docker, however, it’s also easy to accumulate an excessive number of unused images, containers, and data volumes that clutter the output and consume disk space.
docker system prune
To additionally remove any stopped containers and all unused images (not just dangling images), add the -a flag to the command:
docker system prune -a
version: '3'
services:
couchserver:
image: "couchdb:3.1.1"
initializer:
image: curlimages/curl
deploy:
restart_policy:
condition: on-failure
depends_on:
- couchserver
command: ["sh","-c","sleep 15 && curl -u newton:pass-X PUT couchserver:5984/_users && curl -u user:pass-X PUT couchserver:5984/test"]