Build Couchbase local environment with Docker

Overview

A memo when building a local environment of Couchbase with Docker

background

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.

Purpose

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 http://0.0.0.0:8091/ 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. ..

Coded

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
local-env
├ docker-compose.yaml
└ mbe-couchbase-container
  ├ byfield      
  │ └ all.ddoc   #view definition file
  ├ Dockerfile   #Couchbase Docker file
  └ configure.sh #Bash script to configure Couchbase
# docker-compose.yaml
version: "3.7"
services:
  mbe-couchbase:
    build: ./mbe-couchbase-container
    ports:
      - 8091:8091
      - 8092:8092
      - 8093:8093
      - 8094:8094
      - 11210:11210
      - 11211:11211
    environment:
      - COUCHBASE_ADMINISTRATOR_USERNAME=couchbase
      - COUCHBASE_ADMINISTRATOR_PASSWORD=lcouchbase1

--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 ./configure.sh /opt/couchbase
COPY ./byfield/ /opt/couchbase

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

#Server startup
/entrypoint.sh 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 http://127.0.0.1:8091/pools/default -d memoryQuota=4096 -d indexMemoryQuota=4096

#Service settings
curl -v http://127.0.0.1:8091/node/controller/setupServices -d services=kv%2cn1ql%2Cindex

#Couchbase server credentials settings
curl -v http://127.0.0.1:8091/settings/web -d port=8091 -d username=$COUCHBASE_ADMINISTRATOR_USERNAME -d password=$COUCHBASE_ADMINISTRATOR_PASSWORD

#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)
curl -v -u $COUCHBASE_ADMINISTRATOR_USERNAME:$COUCHBASE_ADMINISTRATOR_PASSWORD -X POST http://127.0.0.1:8091/internalSettings -d maxBucketCount=20

#Bucket creation
curl -v -u $COUCHBASE_ADMINISTRATOR_USERNAME:$COUCHBASE_ADMINISTRATOR_PASSWORD -X POST http://127.0.0.1:8091/pools/default/buckets -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" http://127.0.0.1:8092/bucket_name/_design/api%2Ftest -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.

Impressions

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.

reference

https://blog.couchbase.com/docker-deploy-containerized-java-couchbase-web-application/

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