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 execute a script when I terminate a docker container
  • My docker data-only container is empty
  • Why is the Node.js AWS-SDK returning the wrong SQS queue URL when creating a local queue
  • How to save log files from docker container?
  • Is there a way to tell gradle which profiles should be used for the tests?
  • How to correctly graphically ssh -X into 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/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!!!

  • ECONNREFUSED nodeJS with express inside docker container
  • Upgrade docker-compose version on windows 7
  • Kafka log directories in Docker
  • Push Docker Images to Google Cloud using Visual Studio Online
  • Docker on Windows: how to connect to container from host using container IP?
  • Error trying to install Ansible in Jenkins image
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.