Hello,
Just a beginner on Rancher.
I’d like to setup Cassandra listen_address=actual IP address of Rancher like 10.42.X.X
RANCHER_IP=ip addr | grep inet | grep 10.42 | tail -1 | awk '{print $2}' | awk -F\/ '{print $1}'
it works in Container inside after Container is created.
but it doesn’t work on Docker file or any other script for image creation.
Would you share your idea how to get real Rancher container IP before container is created (in Docker file) ?
The Rancher IP address is the second IP address of the NIC after the container is started.
Why can’t you just listen on 0.0.0.0?
A Dockerfile is used to generate the image, information like IP address is dynamic and it’s not a good idea to embed that while building the container image.
The other thing you can do is have a script for the container startup which finds the IP address of the interface and sets the environment variable or pass the parameter while starting cassandra.
Yes, that is my problem
the script like
#!/bin/bash
RANCHER_IP=ip addr | grep inet | grep 10.42 | tail -1 | awk ‘{print $2}’ | awk -F/ ‘{print $1}’
it only works in Container inside after Container is created.
but it doesn’t work on Docker file or any other script for image creation.
Docker file starts up Cassandra, but it doesn’t know RANCHER_IP at that moment, RANCHER_IP is null at that moment.
What I meant was, you can modify the Dockerfile to run your script instead of cassandra. Point it to your script and the script will get the IP and then it will launch cassandra. Look for ENTRYPOINT or CMD in the Dockerfile.