
CouchDB is an open-source document-oriented database that stores data as JSON documents. It provides a RESTful HTTP API for all database operations, built-in replication, and multi-version concurrency control. CouchDB's schema-free design makes it ideal for log storage where document structures may vary, and its HTTP-based interface simplifies integration with log collection tools.
In this article, you will deploy CouchDB using Docker Compose, configure persistent storage for database files, and set up Traefik as a reverse proxy to securely access your CouchDB instance.
Before you begin, you need to:
sudo privileges.couchdb.example.com).In this section, you prepare the required directory structure for CouchDB and define environment variables in a .env file.
Create the directory structure for CouchDB.
This directory stores database files, views, and configuration settings.
Navigate into the couchdb-logging directory.
Set proper ownership for the CouchDB data directory. CouchDB runs as the couchdb user (UID 5984) inside the container.
Create a .env file.
Add the following variables:
Replace:
couchdb.example.com with your domain.admin@example.com with your email.changeme with a strong password.Save and close the file.
In this section, you create and deploy the Docker Compose stack that runs CouchDB behind Traefik. Docker Compose manages both containers, applies the environment variables from your .env file, and automatically configures HTTPS routing through Traefik.
Create a new Docker Compose manifest.
Add the following content.
Save and close the file.
This configuration includes:
./couchdb-data) preserves database files and documents across restarts.letsencrypt maintains SSL certificate storage independently./var/run/docker.sock:ro) enables dynamic container detection..env file.Create and start the services.
Verify that the services are running.
Output:
Both containers are operational. CouchDB accepts database requests while Traefik manages connections on ports 80 and 443.
View the logs of the services.
For more information on managing a Docker Compose stack, see the How To Use Docker Compose article.
This section shows how to confirm your CouchDB installation by accessing the Fauxton web console and executing fundamental database operations via the RESTful HTTP interface.
Open the CouchDB web interface in your browser.
Sign in with the credentials you configured in the .env file:
COUCHDB_USER (default: admin)COUCHDB_PASSWORDThe Fauxton interface displays. This web-based administration console allows you to manage databases, documents, and replication settings.
Verify CouchDB is responding using the command line.
Output:
Create a test database.
Replace admin:changeme with your actual credentials.
Output:
Insert a sample log document.
Output includes the document ID and revision:
Retrieve all documents from the database.
The response confirms your document was stored successfully.
You have successfully deployed CouchDB for log management with HTTPS encryption. The containerized architecture pairs the document database with automated certificate management, ensuring data persistence across service restarts through bind-mounted volumes. Traefik handles SSL termination and request routing while Let's Encrypt provisions trusted certificates. Your CouchDB deployment can now accept JSON log documents via its RESTful interface, support real-time replication across nodes, and enable advanced log analysis through MapReduce queries and the Fauxton web console.
0 Comments
Be the first to comment and share your perspective with the community.