Docker registering containers address as a host on Zookeeper

I’m trying to implement a Docker container which can provide a two way communication. This container when comes up, registers itself on the zookeeper which is on LAN.

Dockerfile is provided below.

  • scan-and-scroll doesn't work from Docker with a ElasticSearch cluster placed outside
  • Docker: multiple sites with common containers
  • Dynamically assigns different value for the environment variable upon a Docker service scale
  • Is Memory consumption is also Dynamic just like CPU for Docker Containers
  • Minor change in ansible playbook does not get updated in target host
  • Getting code inside the Docker container
  • FROM java:7
    EXPOSE 7100
    ARG version
    ENV version=$version
    ARG port
    ENV port=$port
    RUN mkdir -p /cacheDir/services/live/prediction/p$port/$version/logs
    RUN ls -tlr /cacheDir/services/live/prediction/p$port/
    RUN mkdir -p /cacheDir/services/releases/prediction/p$port/$version/
    RUN mkdir -p /cacheDir/services/predictionmodel
    ADD target/predictionDependencies/* /cacheDir/services/predictionmodel/
    ADD /target/prediction-0.0.13-SNAPSHOT.jar /cacheDir/services/releases/prediction/p$port/$version/prediction-0.0.13-SNAPSHOT.jar
    ADD /target/ /cacheDir/services/releases/prediction/p$port/$version/
    ADD /target/logback.xml /cacheDir/services/releases/prediction/p$port/$version/logback.xml
    RUN ls -ltr /cacheDir/services/live/prediction/p$port/$version/
    RUN ls -ltr /cacheDir/services/releases/prediction/p$port/$version/
    RUN ls -ltr /cacheDir/services/predictionmodel
    ENTRYPOINT ["sh","-c","java -server -Xmx2g -Xloggc:/cacheDir/services/live/prediction/p${port}/${version}/logs/gc.log -verbose:gc -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/cacheDir/services/live/prediction/p${port}/${version}/oom.dump -Dlogback.configurationFile=/cacheDir/services/releases/prediction/p${port}/${version}/logback.xml -Dlog.home=/cacheDir/services/live/prediction/p${port}/${version}/logs -Dlogback.debug=true -Dbroker.l^,,, -jar /cacheDir/services/releases/prediction/p${port}/${version}/prediction-0.0.13-SNAPSHOT.jar $port /cacheDir/services/releases/prediction/p${port}/${version}/ /com/wizecommerce/services/$ZK_PATH"]

    Command used to build the docker file.

    docker build --build-arg version=v4 --build-arg port=7100 -t prediction:v4 .

    The images creates successfully. Run Command used to register the service on the Zookeeper.

    sudo docker run -p 7100:7100 -e ZK_PATH=qa -v ~/PredictionVolume/logs/:/cacheDir/services/live/prediction/p7100/v4/logs/  -t prediction:v4

    The service comes up successfully, and the container is able to access the Zookeeper IP address and gets register there. However, the IP address with it which gets registers on the Zookeeper is really strange.


    It looks as if the Zookeeper’s host is registered with the container’s MAC Address.

    What I did, is that I manually changed the host address to my System’s IP. On doing that, it successfully gets up and the process work fine as expected.
    I want that whenever I use my docker’s run command, my system’s IP should get register on the Zookeeper rather than container’s IP.

    Additionally, I also want to know what if I use my machine’s IP address with the run command like this provided below. What exactly does this command means and also how it differs from the previous run command used.

    sudo docker run -p x.y.z.a:7100:7100 -e ZK_PATH=qa -v ~/PredictionVolume/logs/:/cacheDir/services/live/prediction/p7100/v4/logs/  -t prediction:v4

    where x,y,z,a lies in the IPv4 segments range (0-255).

    Also, please let me know if any other information is needed which I may have missed out.
    Thank you very much for the help!!!

  • Docker: Is it possible to share data between 2 containers without a volume?
  • How to expose more ports on a running docker container
  • What is the difference b/w a docker image generated by docker-compose build vs docker build?
  • Why Docker container doesnt resolve hosts as defined in /etc/hosts on Host machine?
  • Docker, communicating between hosts on different bridges
  • Docker - connection between containers in different hosts within the same overlay network
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.