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.

  • Error while building docker
  • dockerizing wordpress with mysql installed on the host machine
  • war-file as a part of container or shared folder when running docker
  • Re-running docker-compose in Windows says network configuration changed
  • Dealing with “HTTP request timed out. Exiting.” when building a large aspnet project for Docker
  • celery won't connect to rabbitmq broker for kubernetes
  • 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/instance.properties /cacheDir/services/releases/prediction/p$port/$version/instance.properties
    
    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^Ct=sv-kafka6.pv.sv.nextag.com:9092,sv-kafka7.pv.sv.nextag.com:9092,sv-kafka8.pv.sv.nextag.com:9092,sv-kafka9.pv.sv.nextag.com:9092 -jar /cacheDir/services/releases/prediction/p${port}/${version}/prediction-0.0.13-SNAPSHOT.jar $port /cacheDir/services/releases/prediction/p${port}/${version}/instance.properties /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.

    {"serviceEndpoint":{"host":"f88bf2357c97","port":7100},"additionalEndpoints":{},"status":"ALIVE","shard":0}
    

    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 shows inconsistent behaviour when creating container from image
  • How to mask multiple Docker containers to a single public IP on Windows 10/ Server 2016
  • log_driver param doesn't work on ansible 2.0
  • Docker Compose Expose Spark Worker UI Ports Dynamically to Host When Scaling
  • Websocket (ws4py in Python 3.5) not working in Docker container
  • Restart ecs-agent from user-data
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.