Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 带集群配置的Couchbase docker入口点_Bash_Docker_Couchbase - Fatal编程技术网

Bash 带集群配置的Couchbase docker入口点

Bash 带集群配置的Couchbase docker入口点,bash,docker,couchbase,Bash,Docker,Couchbase,我正在寻找一种在docker中启动couchbase(6.0.3)的方法,然后在它准备好后,运行一个已知良好的couchbase cli命令(见下文)来设置集群,而无需执行除运行容器之外的任何操作 couchbase-cli cluster-init --cluster "couchbase://127.0.0.1" --cluster-name "couchbase" --cluster-username "admin" --cluster-password "password" --serv

我正在寻找一种在docker中启动couchbase(6.0.3)的方法,然后在它准备好后,运行一个已知良好的couchbase cli命令(见下文)来设置集群,而无需执行除运行容器之外的任何操作

couchbase-cli cluster-init --cluster "couchbase://127.0.0.1" --cluster-name "couchbase" --cluster-username "admin" --cluster-password "password" --services "data,index,query" --cluster-ramsize 500 --cluster-index-ramsize 256 --index-storage-setting "memopt";
到目前为止,我试图使用docker compose的
命令
关键字来解决这个问题,如下所示

version: '2.4'

services:
  couchbase:
    image: couchbase:6.0.3
    container_name: "couchbase"
    restart: always
    ports:
      - 8091-8094:8091-8094
      - 11210:11210
    command: >
      /bin/bash -c "
        until curl -I -s http://localhost:8091/ui/index.html
        do
            echo 'Waiting for Couchbase to start (retrying in 3 seconds)...'
            sleep 3
        done
        couchbase-cli cluster-init --cluster "couchbase://127.0.0.1" --cluster-name "couchbase" --cluster-username "admin" --cluster-password "password" --services "data,index,query" --cluster-ramsize 500 --cluster-index-ramsize 256 --index-storage-setting "memopt"
      "
这导致了打印
等待Couchbase启动(3秒钟后重试)
的无休止循环,Couchbase无法在localhost:8091上访问

然后我改变了策略,决定基于couchbase映像创建自己的Dockerfile,将入口点更改为包含couchbase cli命令,如下所示

Dockerfile:

FROM couchbase:6.0.3
RUN mkdir files
COPY initcouchbase.sh files/
RUN chmod +x files/initcouchbase.sh
ENTRYPOINT ./files/initcouchbase.sh
initcouchbase.sh

#!/usr/bin/env bash

/entrypoint.sh couchbase-server &

until curl -I -s http://localhost:8091/ui/index.html
do
    echo 'Waiting for Couchbase to start (retrying in 3 seconds)...'
    sleep 3
done

couchbase-cli cluster-init --cluster "couchbase://127.0.0.1" --cluster-name "couchbase" --cluster-username "admin" --cluster-password "password" --services "data,index,query" --cluster-ramsize 500 --cluster-index-ramsize 256 --index-storage-setting "memopt"
这种情况下,当docker日志显示集群已配置cli命令成功消息(
success:cluster initialized
)一段时间后,就可以登录到本地集群。然而,过了一会儿,某个东西决定再次运行(我假设整个
initcouchbase.sh
被反复运行),这使得couchbase在几秒钟内再次不可用,直到每次循环完成

有人也尝试过并征服了它吗?除了下面的链接外,我在这里看不到关于这个特定用例的更多内容,但答案没有涵盖我问题的要点


假设这是一个开发环境,您熟悉wait-for-it.sh吗或者另一个工具可能是couchbasefakeit docker image——假设这是一个开发环境,您熟悉wait-for-it.sh吗或者另一个工具可能是couchbasefakeit docker image-