Skip to content

Configuration from docker config or secret? #73

Closed
@endyjasmi

Description

@endyjasmi

I am trying to run CouchDB cluster with this image in production and everything works fine. My question is, is there anyway for us to mount config file from docker swarm config or secret. Currently doing so will cause the image to complain about chmod againts read only file system.

Expected Behavior

CouchDB should be able to read the docker swarm secret mounted at /opt/couchdb/etc/local.d/config.ini.

Current Behavior

Complain about changing permission for read only file system on boot.

Possible Solution

Maybe remove the chmod command at docker-entrypoint.sh?

Steps to Reproduce (for bugs)

  1. Prepare a sample config.ini
  2. Create a docker-compose.yml file with the following content;
version: "3.5"

networks:
  network:
    driver: overlay

secrets:
  config:
    file: ./config.ini

services:
  server-0:
    environment:
      COUCHDB_PASSWORD: -pbkdf2-847043acc65626c8eb98da6d78682fbc493a1787,f7b1a3e4b624f4f0bbfe87e96841eda0,10 // <- password
      COUCHDB_SECRET: 0123456789abcdef0123456789abcdef
      COUCHDB_USER: couchdb
      NODENAME: couchdb-0.docker.com
    image: couchdb:2.1.1
    networks:
      network:
        aliases:
          - couchdb-0.docker.com
    ports:
      - "5984:5984"
      - "5986:5986"
    secrets:
      - source: config
        target: /opt/couchdb/etc/local.d/config.ini
        uid: "5984"
        gid: "5984"
        mode: 0444
    volumes:
      - "volume-0:/opt/couchdb/data"
  server-1:
    environment:
      COUCHDB_PASSWORD: -pbkdf2-847043acc65626c8eb98da6d78682fbc493a1787,f7b1a3e4b624f4f0bbfe87e96841eda0,10
      COUCHDB_SECRET: 0123456789abcdef0123456789abcdef
      COUCHDB_USER: couchdb
      NODENAME: couchdb-1.docker.com
    image: couchdb:2.1.1
    networks:
      network:
        aliases:
          - couchdb-1.docker.com
    ports:
      - "15984:5984"
      - "15986:5986"
    secrets:
      - source: config
        target: /opt/couchdb/etc/local.d/config.ini
        uid: "5984"
        gid: "5984"
        mode: 0444
    volumes:
      - "volume-1:/opt/couchdb/data"
  server-2:
    environment:
      COUCHDB_PASSWORD: -pbkdf2-847043acc65626c8eb98da6d78682fbc493a1787,f7b1a3e4b624f4f0bbfe87e96841eda0,10
      COUCHDB_SECRET: 0123456789abcdef0123456789abcdef
      COUCHDB_USER: couchdb
      NODENAME: couchdb-2.docker.com
    image: couchdb:2.1.1
    networks:
      network:
        aliases:
          - couchdb-2.docker.com
    ports:
      - "25984:5984"
      - "25986:5986"
    secrets:
      - source: config
        target: /opt/couchdb/etc/local.d/config.ini
        uid: "5984"
        gid: "5984"
        mode: 0444
    volumes:
      - "volume-2:/opt/couchdb/data"

volumes:
  volume-0:
  volume-1:
  volume-2:
  1. Run docker stack deploy --compose-file docker-compose.yml couchdb againts a docker swarm.
  2. You can view the log at docker service logs -f couchdb_server-0

Context

Basically I am trying to deploy CouchDB cluster to the production using docker swarm.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions