How to create public container image if I am declaring ip address for mongo db in my nodejs app like:
const client = mongoose.connect("mongodb://192.168.99.100:27017/db", ...
const publicIp = require('public-ip');
(async () => {
console.log(await publicIp.v4());
//=> '46.5.21.123'
console.log(await publicIp.v6());
//=> 'fe80::200:f8ff:fe21:67cf'
})();
Do I have to know from top which addresses container will use?
Or there is some approach any convention like i.e if containers run on one pod they share same internal local address 127.0.0.1?
You should look at Kubernetes Services. Pod and the containers inside them are meant to be ephemeral. As mentioned in the link:
While each Pod gets its own IP address, even those IP addresses cannot be relied upon to be stable over time.
On the other hand, Services have stable IP address. They also allow discovery using environment variables and DNS as specified in the same link.