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.

  • How to push only specific change in docker image
  • Writing Dockerfile for Dockerhub Automated builds
  • how can I open a flask app on my browser that's running remotely on docker?
  • Increasing docker volume size using docker-compose
  • Secrets with containerized single-node kubernetes cluster
  • Sporadic (Authentication??) Failures and Expirations in MongoDb
  • 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!!!

  • Can't visit `` after starting docker registry
  • docker-compose psql could not connect to server
  • docker secrets for configuration files
  • “500 Internal Server Error” when pushing docker images using gcloud and a service account with “Owner” permission
  • Debug ASP.NET Core on Docker in Visual Studio Code
  • AWS EC2 Container program command line arguments
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.