0

i use docker with zookeeper,

COPY zookeeper-3.4.12.tar.gz /opt
RUN cd /opt && \
        tar -xvf zookeeper-3.4.12.tar.gz
ENV ZK_HOME /opt/zookeeper-3.4.12

the zoo.cfg have many configurations,i want to change these parameters, zoo.cfg

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5

some docker instance change syncLimit = 10,some docker instance change tickTime=1000 should i use ARG,pass these paramters through docker run env?but how to change the zoo.cfg content? i don't want to docker exec -it dockerid,and change the file,then commit.anyother suggestions?

王奕然
  • 3,891
  • 6
  • 41
  • 62
  • Have a look at `Dynamic configuration file` section of this documentation - https://zookeeper.apache.org/doc/r3.5.3-beta/zookeeperReconfig.html. – Pruthvi Kumar Jul 13 '18 at 13:32
  • is it possible to set the values of configurations by environment variables in zoo.cfg file? I mean something like this: tickTime=${THICK_TIME} ? – chubock Jul 13 '18 at 13:41
  • usually when you build a docker image, you create a startup script that generates the needed configuration files on first run. You can easily create a config file from a bash script [using heredocs](https://stackoverflow.com/questions/2953081/how-can-i-write-a-heredoc-to-a-file-in-bash-script) – n00dl3 Jul 13 '18 at 13:58
  • [GNU envsubst](https://www.gnu.org/software/gettext/manual/html_node/envsubst-Invocation.html) may be available (it won't be on a Busybox or Alpine base) and if it is that can be an easy minimal templating system. – David Maze Jul 13 '18 at 14:08
  • i find this post http://steveadams.io/2016/08/18/Environment-Variable-Templates.html – 王奕然 Jul 13 '18 at 23:21

0 Answers0