Install CouchDB using Docker and Docker-compose
.
What is CouchDB?
CouchDB is an open-source NoSQL document database that stores data in JSON-based format and offers HTTP-ready REST-API out of the box.
It can be used as a database backend for web, mobile, or even desktop apps. In contrast, it uses JSON for documents, an HTTP API, & JavaScript/declarative indexing.
Although, CouchDB can be installed on Ubuntu or Linux using Snap, many developers may require to install it using Docker.
What is Docker?
Docker is an open platform for developing, deploying, building applications that uses OS-level virtualization to pack the apps in containers.
Docker allows developers to deploy, run, maintain app containers with ease and offers a better control on the app infrastructure.
Docker runs on desktop and servers, on all known operating systems as Linux, macOS, and Windows.
What is Docker Compose?
Docker Compose is a tool that helps developer to define, run, multi-container Docker applications with ease, by just using one YAML file.
Through this file, you can define your container, services, network, ports, and all required configurations to run your app.
Docker Compose can be installed on Windows, Linux, and macOS.
In this article, we will demonstrate how to install CouchDB on Docker using Docker compose.
Install CouchDB using Docker & Docker Compose
Foremost, make sure you have Docker and Docker Compose installed.
Now let's create the docker-compose.yml
file:
Here is a quick preview:
version: '3'
services:
couchserver:
image: couchdb
restart: always
ports:
- "5984:5984"
environment:
- COUCHDB_USER=admin
- COUCHDB_PASSWORD=YOURPASSWORD
volumes:
- ./dbdata:/opt/couchdb/data
Run your image
From the directory that contains your docker-compose.yml
file, run:
docker-compose up -d
Docker will pull your image and setup everything for you.
Soon as everything set, make sure your CouchDB container is up and running, but the following command:
docker ps
Access CouchDB admin
In order to validate your working CouchDB install, head to http://localhost:5984/
. To access the CouchDB admin, head to http://localhost:5984/_utils/
.
Access CouchDB image
If you want to access your container shell for better control, here is how (replace "YOUR_CONTAINER_NAME" with your container name):
docker exec -it YOUR_CONTAINER_NAME bash
You can use this to change your CouchDB admin credentials, and configurations.