Build Couchbase local environment with Docker


A memo when building a local environment of Couchbase with Docker


There was a local environment for Vagrant, --Startup and build are heavy --No code (black boxed) --Vagrant No one on the team understands (because of the environment created by the person who left the company) There are problems such as.


Replace the local environment with Docker.

Work log

Try moving the couchbase image.

First, let's launch the Couchbase container without making detailed settings.

-Check the image at Couchbase docker hub repository スクリーンショット 2020-09-20 13.48.25.png

→ Since the version of the production environment is 4.5.1, use community-4.5.1.

--Start the container

For the time being, start as described in Description

$ docker run -d --name db -p 8091-8094:8091-8094 -p 11210:11210 couchbase:community-4.5.1

--Container startup confirmation

$ docker ps

↓ Start OK スクリーンショット 2020-09-20 13.57.20.png

--Console operation check

Access with a browser and confirm that the Couchbase console is displayed. 0_0_0_0_8091_ui_index_html__.jpg You can manually set the account and bucket by pressing Setup, but since the purpose is coding, we will skip it here.

Check the operation for the time being. ..


Create Dockerfile, docker-compose.yaml

The following settings are required to set up the local environment. --Create cluster --Service settings --Couchbase server credentials settings --Bucket creation --View settings

Dockerfile (also docker-compose.yaml) is described in order to put the above settings into the code.

#Directory structure
├ docker-compose.yaml
└ mbe-couchbase-container
  ├ byfield      
  │ └ all.ddoc   #view definition file
  ├ Dockerfile   #Couchbase Docker file
  └ #Bash script to configure Couchbase
# docker-compose.yaml
version: "3.7"
    build: ./mbe-couchbase-container
      - 8091:8091
      - 8092:8092
      - 8093:8093
      - 8094:8094
      - 11210:11210
      - 11211:11211

--Set Couchbase credentials with COUCHBASE_ADMINISTRATOR_USERNAME,COUCHBASE_ADMINISTRATOR_PASSWORD --In build: ./mbe-couchbase-container, specify ↓ Dockerfile

#Create Dockerfile
FROM couchbase:community-4.5.1

#Copy the Couchbase initialization shell into the container
COPY ./ /opt/couchbase
COPY ./byfield/ /opt/couchbase

#Couchbase configuration execution shell
CMD [ "/opt/couchbase/" ]
#Couchbase configuration shell
set -m

#Server startup
/ couchbase-server &

#Roughly set the waiting time until the API server starts TODO:I want to detect server startup and proceed with processing.
sleep 30

#Cluster memory allocation
curl -v -X POST -d memoryQuota=4096 -d indexMemoryQuota=4096

#Service settings
curl -v -d services=kv%2cn1ql%2Cindex

#Couchbase server credentials settings

#Bucket cap lift(The maximum number of buckets is 10 by default,,If you want to create more, you need to change with the following settings)

#Bucket creation
curl -v -u $COUCHBASE_ADMINISTRATOR_USERNAME:$COUCHBASE_ADMINISTRATOR_PASSWORD -X POST -d name=bucket_name -d bucketType=couchbase -d ramQuotaMB=100 -d authType=sasl -d saslPassword=ladd_personal_info1

echo "please wait 30 sec..."
sleep 30
#View settings
curl -v -u $COUCHBASE_ADMINISTRATOR_USERNAME:$COUCHBASE_ADMINISTRATOR_PASSWORD -X PUT -H "Content-Type: application/json" -d @/opt/couchbase/all.ddoc

sleep 15

#Foreground execution
fg 1

--Container execution with docker-compose

$ docker-compose up -d mbe-couchbase

Confirm bucket startup.


Couchbase doesn't find many articles even if I google. The official reference was solid and it was just a simple implementation so I didn't have any problems. .. Is Couchbase not popular? It seems that the cloud version came out a while ago, but I don't think it will be used when relocating to the cloud.


Recommended Posts

Build Couchbase local environment with Docker
Build docker environment with WSL
Build DynamoDB local with Docker
Build a Node.js environment with Docker
Build PlantUML environment with VSCode + Docker
Build environment with vue.js + rails + docker
Build Rails environment with Docker Compose
Build WordPress environment with Docker (Local) and AWS (Production)
Build docker + laravel environment with laradock
Build a PureScript development environment with Docker
Build a Wordpress development environment with Docker
[Docker] Build Jupyter Lab execution environment with Docker
Build an environment with Docker on AWS
Build TensorFlow operation check environment with Docker
How to build Rails 6 environment with Docker
Build a Laravel / Docker environment with VSCode devcontainer
Build a WordPress development environment quickly with Docker
Build mecab (NEologd dictionary) environment with Docker (ubuntu)
[Rails] How to build an environment with Docker
[First team development ②] Build an environment with Docker
Wordpress local environment construction & development procedure with Docker
Build debug environment on container --Build local development environment for Rails tutorial with Docker-
Build a local development environment for Rails tutorials with Docker (Rails 6 + PostgreSQL + Webpack)
Pytorch execution environment with Docker
[Docker] Rails 5.2 environment construction with docker
React environment construction with Docker
How to build docker environment with Gradle for intelliJ
Build an environment of Ruby2.7.x + Rails6.0.x + MySQL8.0.x with Docker
Easily build a Vue.js environment with Docker + Vue CLI
[Note] Build a Python3 environment with Docker in EC2
Build Java development environment with WSL2 Docker VS Code
Build Rails (API) x MySQL x Nuxt.js environment with Docker
Rails + MySQL environment construction with Docker
Create a Vue3 environment with Docker!
Node.js environment construction with Docker Compose
Build a Tomcat 8.5 environment with Pleiades 4.8
Environment construction with Docker for beginners
How to build [TypeScript + Vue + Express + MySQL] environment with Docker ~ Express ~
Build a local development environment for Open Distro for Elasticsearch with multiple nodes using Docker
Create SolrCloud verification environment with Docker
Create Laravel environment with Docker (docker-compose)
Build jooby development environment with Eclipse
How to build Rails, Postgres, ElasticSearch development environment with Docker
Build a Node-RED environment with Docker to move and understand
[Environment construction with Docker] Rails 6 & MySQL 8
Build Unity development environment on docker
Build WebRTC Janus with Docker container
Spring Boot gradle build with Docker
Build Go development environment with WSL2 + Docker Desktop + VSCode (Remote --Containers)
Build apache7.4 + mysql8 environment with Docker (with initial data) (your own memo)
I tried to build the environment of PlantUML Server with Docker
How to build [TypeScript + Vue + Express + MySQL] environment with Docker ~ MySQL edition ~
How to build Rails + Vue + MySQL environment with Docker [2020/09 latest version]
Build a development environment for Django + MySQL + nginx with Docker Compose
How to build [TypeScript + Vue + Express + MySQL] environment with Docker ~ Sequelize ~
Alert slack with alert manager in Docker environment
GPU environment construction with Docker [October 2020 version]
Rails environment construction with Docker (personal apocalypse)
Building Rails 6 and PostgreSQL environment with Docker
Laravel development environment construction with Docker (Mac)
Build and manage RStudio environment with Docker-compose