Install CouchDB Inside Docker Container in Linux

Install CouchDB Inside Docker Container in Linux

CouchDB is a cross-platform document database released by the Apache Software Foundation. CouchDB is classified as a NoSQL database. So, it stores data in JSON-based document format. CouchDB is an open-source project written in the Erlang programming language.

This tutorial explains how to install CouchDB inside a Docker container in the Linux. Commands have been tested on Ubuntu.

Prepare environment

Make sure you have installed Docker in your system. If you are using Ubuntu, installation instructions can be found in the post.

Install CouchDB

  • Host network

Run the following command to create a container for CouchDB that uses host network:

docker run -d --name=couchdb --restart=always --network=host \
    -v /opt/couchdb/data:/opt/couchdb/data \
    -e COUCHDB_USER=admin \
    -e COUCHDB_PASSWORD=pwd123 \
    couchdb
  • User-defined bridge network

User-defined bridge network can be used for listening on different port. By default, CouchDB service is listening on port 5984. It can be changed with -p option.

docker network create app-net
docker run -d --name=couchdb --restart=always --network=app-net \
    -p 8080:5984 \
    -v /opt/couchdb/data:/opt/couchdb/data \
    -e COUCHDB_USER=admin \
    -e COUCHDB_PASSWORD=pwd123 \
    couchdb

Note: don't forget to change admin password.

Testing CouchDB

Open a web browser and go to http://<IP_ADDRESS>:5984/_utils, where <IP_ADDRESS> is the IP address of the system. Log in to the dashboard with the admin username and password.

CouchDB Inside Docker Container in Linux

Uninstall CouchDB

To completely remove CouchDB, remove its container:

docker rm --force couchdb

Remove CouchDB image:

docker rmi couchdb

You can also remove CouchDB data:

sudo rm -rf /opt/couchdb

If a user-defined bridge network was created, you can delete it as follows:

docker network rm app-net

Leave a Comment

Cancel reply

Your email address will not be published.