Merge pull request #667 from h-exx/main

Edited the Docker Compose documentation to make it work
This commit is contained in:
vorotamoroz
2025-08-14 14:24:14 +09:00
committed by GitHub

View File

@@ -5,10 +5,15 @@
- [Setup a CouchDB server](#setup-a-couchdb-server) - [Setup a CouchDB server](#setup-a-couchdb-server)
- [Table of Contents](#table-of-contents) - [Table of Contents](#table-of-contents)
- [1. Prepare CouchDB](#1-prepare-couchdb) - [1. Prepare CouchDB](#1-prepare-couchdb)
- [A. Using Docker container](#a-using-docker-container) - [A. Using Docker](#a-using-docker)
- [1. Prepare](#1-prepare) - [1. Prepare](#1-prepare)
- [2. Run docker container](#2-run-docker-container) - [2. Run docker container](#2-run-docker-container)
- [B. Install CouchDB directly](#b-install-couchdb-directly) - [B. Using Docker Compose](#b-using-docker-compose)
- [1. Prepare](#1-prepare-1)
- [2. Creating Compose file](#2-create-a-docker-composeyml-file-with-the-following-added-to-it)
- [3. Boot check](#3-run-the-docker-compose-file-to-boot-check)
- [4. Starting Docker Compose in background](#4-run-the-docker-compose-file-in-the-background)
- [C. Install CouchDB directly](#c-install-couchdb-directly)
- [2. Run couchdb-init.sh for initialise](#2-run-couchdb-initsh-for-initialise) - [2. Run couchdb-init.sh for initialise](#2-run-couchdb-initsh-for-initialise)
- [3. Expose CouchDB to the Internet](#3-expose-couchdb-to-the-internet) - [3. Expose CouchDB to the Internet](#3-expose-couchdb-to-the-internet)
- [4. Client Setup](#4-client-setup) - [4. Client Setup](#4-client-setup)
@@ -21,44 +26,56 @@
--- ---
## 1. Prepare CouchDB ## 1. Prepare CouchDB
### A. Using Docker container ### A. Using Docker
#### 1. Prepare #### 1. Prepare
```bash ```bash
# Prepare environment variables. # Adding environment variables.
export hostname=localhost:5984 export hostname=localhost:5984
export username=goojdasjdas #Please change as you like. export username=goojdasjdas #Please change as you like.
export password=kpkdasdosakpdsa #Please change as you like export password=kpkdasdosakpdsa #Please change as you like
# Prepare directories which save data and configurations. # Creating the save data & configuration directories.
mkdir couchdb-data mkdir couchdb-data
mkdir couchdb-etc mkdir couchdb-etc
``` ```
#### 2. Run docker container #### 2. Run docker container
1. Boot Check. 1. Boot Check.
``` ```
$ docker run --name couchdb-for-ols --rm -it -e COUCHDB_USER=${username} -e COUCHDB_PASSWORD=${password} -v ${PWD}/couchdb-data:/opt/couchdb/data -v ${PWD}/couchdb-etc:/opt/couchdb/etc/local.d -p 5984:5984 couchdb $ docker run --name couchdb-for-ols --rm -it -e COUCHDB_USER=${username} -e COUCHDB_PASSWORD=${password} -v ${PWD}/couchdb-data:/opt/couchdb/data -v ${PWD}/couchdb-etc:/opt/couchdb/etc/local.d -p 5984:5984 couchdb
``` ```
If your container has been exited, please check the permission of couchdb-data, and couchdb-etc. > [!WARNING]
Once CouchDB run, these directories will be owned by uid:`5984`. Please chown it for you again. > If your container threw an error or exited unexpectedly, please check the permission of couchdb-data, and couchdb-etc.
> Once CouchDB starts, these directories will be owned by uid:`5984`. Please chown it for that uid again.
2. Enable it in the background 2. Enable it in the background
``` ```
$ docker run --name couchdb-for-ols -d --restart always -e COUCHDB_USER=${username} -e COUCHDB_PASSWORD=${password} -v ${PWD}/couchdb-data:/opt/couchdb/data -v ${PWD}/couchdb-etc:/opt/couchdb/etc/local.d -p 5984:5984 couchdb $ docker run --name couchdb-for-ols -d --restart always -e COUCHDB_USER=${username} -e COUCHDB_PASSWORD=${password} -v ${PWD}/couchdb-data:/opt/couchdb/data -v ${PWD}/couchdb-etc:/opt/couchdb/etc/local.d -p 5984:5984 couchdb
``` ```
If you prefer a compose file instead of docker run, here is the equivalent below:
Congrats, move on to [step 2](#2-run-couchdb-initsh-for-initialise)
### B. Using Docker Compose
#### 1. Prepare
```
# Creating the save data & configuration directories.
mkdir couchdb-data
mkdir couchdb-etc
```
#### 2. Create a `docker-compose.yml` file with the following added to it
``` ```
services: services:
couchdb: couchdb:
image: couchdb:latest image: couchdb:latest
container_name: couchdb-for-ols container_name: couchdb-for-ols
user: 1000:1000 user: 5984:5984
environment: environment:
- COUCHDB_USER=${username} - COUCHDB_USER=<INSERT USERNAME HERE> #Please change as you like.
- COUCHDB_PASSWORD=${password} - COUCHDB_PASSWORD=<INSERT PASSWORD HERE> #Please change as you like.
volumes: volumes:
- ./couchdb-data:/opt/couchdb/data - ./couchdb-data:/opt/couchdb/data
- ./couchdb-etc:/opt/couchdb/etc/local.d - ./couchdb-etc:/opt/couchdb/etc/local.d
@@ -66,7 +83,30 @@ services:
- 5984:5984 - 5984:5984
restart: unless-stopped restart: unless-stopped
``` ```
### B. Install CouchDB directly
#### 3. Run the Docker Compose file to boot check
```
docker compose up
# Or if using the old version
docker-compose up
```
> [!WARNING]
> If your container threw an error or exited unexpectedly, please check the permission of couchdb-data, and couchdb-etc.
> Once CouchDB starts, these directories will be owned by uid:`5984`. Please chown it for that uid again.
#### 4. Run the Docker Compose file in the background
If all went well and didn't throw any errors, `CTRL+C` out of it, and then run this command
```
docker compose up -d
# Or if using the old version
docker-compose up -d
```
Congrats, move on to [step 2](#2-run-couchdb-initsh-for-initialise)
### C. Install CouchDB directly
Please refer to the [official document](https://docs.couchdb.org/en/stable/install/index.html). However, we do not have to configure it fully. Just the administrator needs to be configured. Please refer to the [official document](https://docs.couchdb.org/en/stable/install/index.html). However, we do not have to configure it fully. Just the administrator needs to be configured.
## 2. Run couchdb-init.sh for initialise ## 2. Run couchdb-init.sh for initialise