For production purposes, we recommend using publicly trusted certificates issued by a Certificate Authority (CA).
Components
- CouchDB image built by Minimus: CouchDB listens only on HTTPS (5984); HTTP is disabled.
- Dynamic certificate generation via OpenSSL:
- certgen.sh script: Shell script that generates a custom CA, server, and client certificates using OpenSSL.
- minidebug image: A Minimus dev toolkit that provides a shell, OpenSSL, and other utilities used to generate the certificates.
What this guide demonstrates
- TLS handshake validation
- Server/client certificate trust
- Basic auth and CouchDB operations
Directory structure
Deploy CouchDB with self-signed TLS certificates
Step 1: Generate TLS certificates
1
Save script that generates TLS certificates
Save the following script to a file named
certgen.sh. The script is used to generate the TLS certificates and store them in a certs folder on the host.certgen.sh
2
Save Docker Compose configuration
Save the following YAML configuration to a file named
create-certs.yml. The configuration uses the Minimus minidebug image to generate the certificates with the certgen.sh shell script. Minidebug is a secure Minimus dev toolkit that provides a shell, OpenSSL, and other utilities.The certificates will be persisted in the certs volume on the host.create-certs.yml
3
Generate certificates
Run the following to generate the certificates:
- CA certificate (
ca.pem) - Server certificates (
server-cert.pem,server-key.pem) - Client certificates (
client.pem,client-key.pem)
local.ini.
Step 2: Deploy CouchDB server
1
Save couchdb-local.ini
Save the following configuration to a file named
couchdb-local.ini:couchdb-local.ini
2
Save Docker Compose script
Save the following Docker Compose script to If you don’t yet have the folder
docker-compose.yml. This compose file sets up CouchDB using TLS (HTTPS only), with authentication enabled, mounts the generated certificates, uses the configurations in the local INI file, and exposes CouchDB over https://localhost:15984.docker-compose.yml
./data ready and waiting, create it and give it permissions:3
Run CouchDB
Start the CouchDB container:
Step 3: Test your CouchDB server
Connect to your database and test its connectivity. For example, here are a few commands you can try out:-
Check server health:
You should get the response
{"seeds":{},"status":"ok"}. -
Create and delete a database (for example
testdb): -
List all databases:
You can also pass the request for a JSON format. This option requires the jq JSON processor.
-
Check if a database exists:
-
Create document: