umbrel-apps icon indicating copy to clipboard operation
umbrel-apps copied to clipboard

ENV for the `UMBREL_IP`

Open chevdor opened this issue 2 years ago • 1 comments

Short version

Is there is a way to get the Umbrel IP ?

Details

I have an App made of a few containers. One container exposes a service (prometheus metrics...) on :9615. The IP for this container is set so I know the internal IP.

Docker is set to expose :9615 (:28415 but this is a random pick and this is not very relevant...)

  • curl http://localhost:28415/metrics from the Umbrel server => OK
  • http://10.211.55.20:28415/metrics from "outside" => OK (10.211.55.20 is the IP Umbrel got)

I have a container that runs a static site. This site runs in the user's browser so it needs the public IP of the Umbrel server: 10.211.55.20 in order to access the prometheus metrics.

How can I retreive the Umbrel external IP in order to pass it as an ENV to my nginx container ?

chevdor avatar Jul 05 '23 13:07 chevdor

I believe you can just point the IP address to the Umbrel's container name and your site will open in the browser fine.

IMPranshu avatar Jul 11 '23 06:07 IMPranshu

Hey @chevdor, the easiest way to have container's talk to each other is to leverage Docker DNS. So as @IMPranshu says you would use the name of the docker container that you want to communicate with, and Docker DNS will resolve this name to the container's IP address.

See the Immich app, for example, where the container name (immich_machine-learning_1) is used as the hostname in this environment variable:

https://github.com/getumbrel/umbrel-apps/blob/d3a0d959f92a9de851a5b55b59b196906388ffb1/immich/docker-compose.yml#L15

Docker DNS will then resolve this to the container's IP for you.

Is there is a way to get the Umbrel IP ?

But if you are looking to get the local IP of your Umbrel device, the current way you would do that is by running something like: hostname --all-ip-addresses ...and parsing the IP address you want.

See Nextcloud as an example: https://github.com/getumbrel/umbrel-apps/blob/master/nextcloud/exports.sh

nmfretz avatar Jun 12 '24 00:06 nmfretz