gluetun
gluetun copied to clipboard
Feature request: Getting the IP and forwarded port in an env file?
What's the feature 🧐
Hi,
I have another container that I'd like to connect to Gluetun, which uses environment variables to set the IP and forwarded port.
Right now, I can indeed mount the /forwarded_port and /ip files in my second container as per the wiki, but I still cant assign their content to the second container's environment variables.
Would be handy to have the /forwarded_port and /ip file act as .env files, that is to say with the VAR=VAL format instead of just VAL.
Even better, if we could somehow decide what should be the VAR name in these files, so that we'd just have to mount them as env files in the client containers.
Not sure if that makes sense?
Cheers
Extra information and references
No response
The problem with your approach is that when Gluetun auto-heals, the IP could change. Also when the port forwarded expires, it will change. And your associated container won't be notified of the changes.
I would suggest modifying the entrypoint of the container so you cat the values from the files and then set them as environment variables before calling the actual image built-in entrypoint. You can also query the control server on port 8000
(see the Wiki) to get the ip and forwarded port if you prefer. Ideally you should have your 2nd container poll the control server periodically such that you can detect changes in the ip and/or port fowarded.
What do you think?
Hah! That makes sense. I will do as you say then, thanks for the info :)
Can you link to the part of the wiki that mentions "query the control server on port 8000" ?. I cant find it.
nevermind - found it here