0

I am trying to understand the dockerfile here after ( it comes from here : https://hub.docker.com/r/jplock/zookeeper/~/dockerfile/ )

What I don't understand is the VOLUME ["/opt/zookeeper/conf", "/tmp/zookeeper"] part...

From Docker's doc I read :

    The VOLUME instruction creates a mount point with the specified name 
and marks it as holding externally mounted volumes from native host or 
other containers. The value can be a JSON array, VOLUME ["/var/log/"], or a 
plain string with multiple arguments, such as VOLUME /var/log or VOLUME 
/var/log /var/db. For more information/examples and mounting instructions 
via the Docker client, refer to Share Directories via Volumes 
documentation.

So What I understand is that I could have a local file which would take place of the container's file. So I created a file in my local hard-drive :

$ cat /opt/zookeeper/conf/zoo.cfg
# The number of milliseconds of each tick
tickTime=3000

And hope the [VOLUME] function would place it on top of the by default [zoo.cfg] in the container. Unfortunately, launching the container I still see a ticktime at 2000 (last line) :

ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/bin/../conf/zoo.cfg
2016-12-05 13:13:18,728 [myid:] - INFO  [main:QuorumPeerConfig@124] - Reading configuration from: /opt/zookeeper/bin/../conf/zoo.cfg
2016-12-05 13:13:18,736 [myid:] - INFO  [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3
2016-12-05 13:13:18,737 [myid:] - INFO  [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 0
2016-12-05 13:13:18,738 [myid:] - INFO  [main:DatadirCleanupManager@101] - Purge task is not scheduled.
2016-12-05 13:13:18,740 [myid:] - WARN  [main:QuorumPeerMain@113] - Either no config or no quorum defined in config, running  in standalone mode
2016-12-05 13:13:18,763 [myid:] - INFO  [main:QuorumPeerConfig@124] - Reading configuration from: /opt/zookeeper/bin/../conf/zoo.cfg
2016-12-05 13:13:18,764 [myid:] - INFO  [main:ZooKeeperServerMain@96] - Starting server
2016-12-05 13:13:18,781 [myid:] - INFO  [main:Environment@100] - Server environment:zookeeper.version=3.4.9-1757313, built on 08/23/2016 06:50 GMT
2016-12-05 13:13:18,781 [myid:] - INFO  [main:Environment@100] - Server environment:host.name=11586b93e1ff
2016-12-05 13:13:18,782 [myid:] - INFO  [main:Environment@100] - Server environment:java.version=1.8.0_92-internal
2016-12-05 13:13:18,782 [myid:] - INFO  [main:Environment@100] - Server environment:java.vendor=Oracle Corporation
2016-12-05 13:13:18,783 [myid:] - INFO  [main:Environment@100] - Server environment:java.home=/usr/lib/jvm/java-1.8-openjdk/jre
2016-12-05 13:13:18,783 [myid:] - INFO  [main:Environment@100] - Server environment:java.class.path=/opt/zookeeper/bin/../build/classes:/opt/zookeeper/bin/../build/lib/*.jar:/opt/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar:/opt/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/opt/zookeeper/bin/../lib/netty-3.10.5.Final.jar:/opt/zookeeper/bin/../lib/log4j-1.2.16.jar:/opt/zookeeper/bin/../lib/jline-0.9.94.jar:/opt/zookeeper/bin/../zookeeper-3.4.9.jar:/opt/zookeeper/bin/../src/java/lib/*.jar:/opt/zookeeper/bin/../conf:
2016-12-05 13:13:18,784 [myid:] - INFO  [main:Environment@100] - Server environment:java.library.path=/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64:/usr/lib/jvm/java-1.8-openjdk/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2016-12-05 13:13:18,785 [myid:] - INFO  [main:Environment@100] - Server environment:java.io.tmpdir=/tmp
2016-12-05 13:13:18,785 [myid:] - INFO  [main:Environment@100] - Server environment:java.compiler=<NA>
2016-12-05 13:13:18,789 [myid:] - INFO  [main:Environment@100] - Server environment:os.name=Linux
2016-12-05 13:13:18,789 [myid:] - INFO  [main:Environment@100] - Server environment:os.arch=amd64
2016-12-05 13:13:18,790 [myid:] - INFO  [main:Environment@100] - Server environment:os.version=4.4.27-moby
2016-12-05 13:13:18,790 [myid:] - INFO  [main:Environment@100] - Server environment:user.name=root
2016-12-05 13:13:18,791 [myid:] - INFO  [main:Environment@100] - Server environment:user.home=/root
2016-12-05 13:13:18,791 [myid:] - INFO  [main:Environment@100] - Server environment:user.dir=/opt/zookeeper
2016-12-05 13:13:18,803 [myid:] - INFO  [main:ZooKeeperServer@815] - tickTime set to 2000

So I don't understand the VOLUME Commande :(

FROM openjdk:8-jre-alpine
MAINTAINER Justin Plock <justin@plock.net>

ARG MIRROR=http://apache.mirrors.pair.com
ARG VERSION=3.4.9

LABEL name="zookeeper" version=$VERSION

RUN apk add --no-cache wget bash \
    && mkdir /opt \
    && wget -q -O - $MIRROR/zookeeper/zookeeper-$VERSION/zookeeper-$VERSION.tar.gz | tar -xzf - -C /opt \
    && mv /opt/zookeeper-$VERSION /opt/zookeeper \
    && cp /opt/zookeeper/conf/zoo_sample.cfg /opt/zookeeper/conf/zoo.cfg \
    && mkdir -p /tmp/zookeeper

EXPOSE 2181 2888 3888

WORKDIR /opt/zookeeper

VOLUME ["/opt/zookeeper/conf", "/tmp/zookeeper"]

ENTRYPOINT ["/opt/zookeeper/bin/zkServer.sh"]
CMD ["start-foreground"]
Mandeep Thakur
  • 655
  • 1
  • 10
  • 23
Romain Jouin
  • 4,448
  • 3
  • 49
  • 79
  • You can overwrite the provided mountpoints (volumes) from the container with blockdevices from your host or other containers. For example run this container with -V your/local/path/to:/opt/zookeeper/conf would point the container folder /opt/zookeeper/conf on your/local/path – Rene M. Dec 05 '16 at 13:19
  • what is the VOLUME instruction useful for then ? – Romain Jouin Dec 05 '16 at 13:21
  • You can read? This way you can use a local folder or an other container to hold the persistent data of an other container. For example i start 200 of this containers, when I point them all to the same config volume, I can configure all 200 at once. – Rene M. Dec 05 '16 at 13:22
  • I am not sure I get it :-/ This is meaning that it is data from inside the container which would be saved on the local hard-drive, and not otherwise (ie : hard-drive data mounted inside the container). – Romain Jouin Dec 05 '16 at 13:27
  • If I want to put data saved on the hard-drive into a container, I use [ -V ]. If I want to save container's data into the hard drive, I use [ VOLUME ] ? – Romain Jouin Dec 05 '16 at 13:29
  • the Volumes intigrates a custom defined storage path in your container. This path can be on your host a volume of an other container. Over that you can share data or provide data – Rene M. Dec 05 '16 at 13:30
  • I stil don't get it : after using [ VOLUME ] I don't see any difference on my local hard-drive : my [ tickTime=3000 ] is still here :-/ – Romain Jouin Dec 05 '16 at 13:30
  • ok, so I understand the [ VOLUME ] doesn't appear on the local hard-drive. It is just an open path for another container inside the container. If I have a container [A] having a [VOLUME], how could I read the data in this [VOLUME] from another container [B] ? – Romain Jouin Dec 05 '16 at 13:37

0 Answers0