今天看啥  ›  专栏  ›  赵安家

zookeeper-docker 可以通过环境变量定义zk配置参数

赵安家  · 掘金  ·  · 2018-04-09 11:42

Useage

Clone repo

$ git clone https://github.com/anjia0532/zookeeper-docker.git
$ cd zookeeper-docker

Build

$ docker build --build-arg ZK_VERSION=3.4.10 . -t anjia0532/zookeeper:stable-alpine
$ docker build . -t anjia0532/zookeeper:stable-alpine # default ZK_VERSION is 3.4.11

Set zk config

$ docker run  -d --name zk  -e  ZK_abc_a=1 -e ZK_aBc=1 -e ZK_aB_c=1 anjia0532/zookeeper:3.4.11-alpine && docker container exec zk cat /opt/zk/conf/zoo.cfg
# //output 
# //...
# //aB.c=1
# //abc.a=1
# //aBc=1
  1. ZK_abc_a => abc.a
  2. ZK_aBc => aBc
  3. ZK_aB_c => aB.c

Custom init script

$ docker run  -d --name zk  -e  CUSTOM_INIT_SCRIPT="echo 1 > /opt/zk/data/myid" -e ZK_dataDir="/opt/zk/data/" anjia0532/zookeeper:3.4.11-alpine && docker container exec zk cat /opt/zk/conf/zoo.cfg && docker container exec zk cat /opt/zk/data/myid

#// /opt/zk/conf/zoo.cfg output
#// ...
#// dataDir=/opt/zk/data/
#// ...

#// /opt/zk/data/myid output
#// 1

Thanks

  1. wurstmeister/zookeeper-docker
  2. wurstmeister/kafka-docker
  3. rawmind0/alpine-zk

Feedback

create new issues

Copyright and License

This module is licensed under the BSD license.

Copyright (C) 2017-, by AnJia anjia0532@gmail.com.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.




原文地址:访问原文地址
快照地址: 访问文章快照