regnete edited a comment on issue #74:
URL: https://github.com/apache/couchdb-docker/issues/74#issuecomment-644592838


   @endyjasmi: Thank you for providing a working example. 
   
   I had to made some adjustments to get it working with couchdb 3.1.0. I wan't 
to share this for others running in problems when setting up a couchdb 3 
cluster with docker-compose. Hope, this is usefull for anybody out there.
   
   1. explicitly set an erlang cookie on each node via ENV var. Cookie value 
must be equal on all nodes. Otherwise you will get connection issues between 
nodes (e.g. "Connection attempt from disallowed node")
   ```
       server-0:
            environment:
                 ERL_FLAGS: "-setcookie brumbrum"
   ```
   
   2. Mount the `/opt/couchdb/etc/local.d` directory as volume to have it 
persisted over `docker-compose down` and `docker-compose up -d`. Otherwise each 
node will write new given COUCHDB_PASSWORD's hash on every `docker-compose up 
-d` to /opt/couchdb/etc/local.d/docker.ini. In consequence the hashes for the 
admin passwords differ between nodes and you are ending up with connection 
issues between the nodes (e.g. 'no_majority').
   
   ```
   server-0:
       volumes:
           - "data-couch-0:/opt/couchdb/data"
           - "cfg-couch-0:/opt/couchdb/etc/local.d"
   ```
   
   ```
   volumes:
     data-couch-0:
     cfg-couch-0:
     data-couch-1:
     cfg-couch-1:
     data-couch-2:
     cfg-couch-2:
   ```
   
   3. No need to map Port  5886 to the public
   
   
   Here is the complete content for a docker-compose.yml:
   
   ```
   version: "3.5"
   
   networks:
     network:
   
   services:
     server-0:
       environment:
         COUCHDB_PASSWORD: 
-pbkdf2-847043acc65626c8eb98da6d78682fbc493a1787,f7b1a3e4b624f4f0bbfe87e96841eda0,10
         COUCHDB_SECRET: 0123456789abcdef0123456789abcdef
         COUCHDB_USER: couchdb
         NODENAME: couchdb-0.docker.com
         ERL_FLAGS: "-setcookie brumbrum"
       image: couchdb:3
       networks:
         network:
           aliases:
             - couchdb-0.docker.com
       ports:
         - "5984:5984"
       volumes:
         - "data-couch-0:/opt/couchdb/data"
         - "cfg-couch-0:/opt/couchdb/etc/local.d"
     server-1:
       environment:
         COUCHDB_PASSWORD: 
-pbkdf2-847043acc65626c8eb98da6d78682fbc493a1787,f7b1a3e4b624f4f0bbfe87e96841eda0,10
         COUCHDB_SECRET: 0123456789abcdef0123456789abcdef
         COUCHDB_USER: couchdb
         NODENAME: couchdb-1.docker.com
         ERL_FLAGS: "-setcookie brumbrum"
       image: couchdb:3
       networks:
         network:
           aliases:
             - couchdb-1.docker.com
       ports:
         - "15984:5984"
       volumes:
         - "data-couch-1:/opt/couchdb/data"
         - "cfg-couch-1:/opt/couchdb/etc/local.d"
     server-2:
       environment:
         COUCHDB_PASSWORD: 
-pbkdf2-847043acc65626c8eb98da6d78682fbc493a1787,f7b1a3e4b624f4f0bbfe87e96841eda0,10
         COUCHDB_SECRET: 0123456789abcdef0123456789abcdef
         COUCHDB_USER: couchdb
         NODENAME: couchdb-2.docker.com
         ERL_FLAGS: "-setcookie brumbrum"
       image: couchdb:3
       networks:
         network:
           aliases:
             - couchdb-2.docker.com
       ports:
         - "25984:5984"
       volumes:
         - "data-couch-2:/opt/couchdb/data"
         - "cfg-couch-2:/opt/couchdb/etc/local.d"
   
   volumes:
     data-couch-0:
     cfg-couch-0:
     data-couch-1:
     cfg-couch-1:
     data-couch-2:
     cfg-couch-2:
   ```
   
   see https://github.com/regnete/howto-couchdb-cluster-docker-compose


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to