Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Docker host ip

Featured Replies

Is there any way of passing the unraid host ip as a variable to be able to be used inside a container, not the image at build time obviously, but a container at runtime ?

Is there any way of passing the unraid host ip as a variable to be able to be used inside a container, not the image at build time obviously, but a container at runtime ?

doubt if there's a way through dockerMan, but from the command line you should be able to do something like:

 

docker run -d --net="host" --name="couchpotato" -v /path/to/couchpotato/data:/config -v /path/to/downloads:/downloads -v /path/to/movies:/movies -v /etc/localtime:/etc/localtime:ro -e IP=$(ifconfig br0 | grep 'inet' | awk '{print $2}')
-p 5050:5050 needo/couchpotato

 

You're the expert on environment variables, but that should set the environment variable IP to be the IP address of br0 which should wind up equaling 192.168.xx.xx or whatever

 

Thinking about it, you're probably going to have to put quotations around it  ie: -e IP="$(ifconfig .....)"

  • Author

Is there any way of passing the unraid host ip as a variable to be able to be used inside a container, not the image at build time obviously, but a container at runtime ?

doubt if there's a way through dockerMan, but from the command line you should be able to do something like:

 

docker run -d --net="host" --name="couchpotato" -v /path/to/couchpotato/data:/config -v /path/to/downloads:/downloads -v /path/to/movies:/movies -v /etc/localtime:/etc/localtime:ro -e IP=$(ifconfig br0 | grep 'inet' | awk '{print $2}')
-p 5050:5050 needo/couchpotato

 

You're the expert on environment variables, but that should set the environment variable IP to be the IP address of br0 which should wind up equaling 192.168.xx.xx or whatever

 

i've got a few things in private repo and various stages on my local docker build VM that fall down because they need the host ip in their setup.

 

i could passthrough a variable manually from the dockerman template, but it is not very elegant and not exactly silly person proof either.

  • Author

Is there any way of passing the unraid host ip as a variable to be able to be used inside a container, not the image at build time obviously, but a container at runtime ?

doubt if there's a way through dockerMan, but from the command line you should be able to do something like:

 

docker run -d --net="host" --name="couchpotato" -v /path/to/couchpotato/data:/config -v /path/to/downloads:/downloads -v /path/to/movies:/movies -v /etc/localtime:/etc/localtime:ro -e IP=$(ifconfig br0 | grep 'inet' | awk '{print $2}')
-p 5050:5050 needo/couchpotato

 

You're the expert on environment variables, but that should set the environment variable IP to be the IP address of br0 which should wind up equaling 192.168.xx.xx or whatever

 

i was wondering if the dockerman template [iP] in the template was somehow usable to passthrough as a variable to the container itself.

Is there any way of passing the unraid host ip as a variable to be able to be used inside a container, not the image at build time obviously, but a container at runtime ?

 

172.17.42.1  ::) ::)::)

 

Yes, it's just that simple.

Is there any way of passing the unraid host ip as a variable to be able to be used inside a container, not the image at build time obviously, but a container at runtime ?

 

172.17.42.1  ::) ::)::)

 

Yes, it's just that simple.

 

 

According to the docs:

  https://docs.docker.com/articles/networking/

 

When Docker starts, it creates a virtual interface named docker0 on the host machine. It randomly chooses an address and subnet from the private range defined by RFC 1918 that are not in use on the host machine, and assigns it to docker0.  Docker made the choice 172.17.42.1/16 when I started it a few minutes ago, for example — a 16-bit netmask providing 65,534 addresses for the host machine and its containers.

 

Based on this, it seems that you are not guaranteed to get 172.17.42.1 as your IP.

  • Author

Is there any way of passing the unraid host ip as a variable to be able to be used inside a container, not the image at build time obviously, but a container at runtime ?

 

172.17.42.1  ::) ::)::)

 

Yes, it's just that simple.

 

not the internal docker ip, the unraid host.

When Docker starts, it creates a virtual interface named docker0 on the host machine. It randomly chooses an address and subnet from the private range defined by RFC 1918 that are not in use on the host machine, and assigns it to docker0.  Docker made the choice 172.17.42.1/16 when I started it a few minutes ago, for example — a 16-bit netmask providing 65,534 addresses for the host machine and its containers.

 

Based on this, it seems that you are not guaranteed to get 172.17.42.1 as your IP.

 

Yes, you're right, but unless it's already taken, Docker will always use that subnet.

 

not the internal docker ip, the unraid host.

 

You can get every port of the domain with that address.

  • Author

 

not the internal docker ip, the unraid host.

 

You can get every port of the domain with that address.

 

i'm not making myself clear, (i'm good at that).

 

some apps require the ip at setup for api's etc.....

 

the docker's ip isn't going to work because that's not reachable from outside the container.

 

not the internal docker ip, the unraid host.

 

You can get every port of the domain with that address.

 

i'm not making myself clear, (i'm good at that).

 

some apps require the ip at setup for api's etc.....

 

the docker's ip isn't going to work because that's not reachable from outside the container.

 

The most affordable way is to map /var/local/emhttp/var.ini as RO and extract the IPADDR variable.

  • Author

 

not the internal docker ip, the unraid host.

 

You can get every port of the domain with that address.

 

i'm not making myself clear, (i'm good at that).

 

some apps require the ip at setup for api's etc.....

 

the docker's ip isn't going to work because that's not reachable from outside the container.

 

The most affordable way is to map /var/local/emhttp/var.ini as RO and extract the IPADDR variable.

 

cool, that works nicely, it's a simple little script to get the value, thanks..

 

The most affordable way is to map /var/local/emhttp/var.ini as RO and extract the IPADDR variable.

 

cool, that works nicely, it's a simple little script to get the value, thanks..

 

Unfortunately, that is an unraid-specific solution, it would be nice if there was a more generic solution.

 

Along these lines, do you know of a way for a Dockerfile to tell if it was started in host mode vs bridge mode? 

 

It would be ideal if Needo's PlexWatch could do this, and then configure itself:

  • If host mode, connect to Plex running on "localhost"
  • If bridge mode, connect to the host ip (or 172.17.42.1, if that is really safe to use)
     

  • Author

 

The most affordable way is to map /var/local/emhttp/var.ini as RO and extract the IPADDR variable.

 

cool, that works nicely, it's a simple little script to get the value, thanks..

 

Unfortunately, that is an unraid-specific solution, it would be nice if there was a more generic solution.

 

Along these lines, do you know of a way for a Dockerfile to tell if it was started in host mode vs bridge mode? 

 

It would be ideal if Needo's PlexWatch could do this, and then configure itself:

  • If host mode, connect to Plex running on "localhost"
  • If bridge mode, connect to the host ip (or 172.17.42.1, if that is really safe to use)
     

 

this IS the unraid forum.

this IS the unraid forum.

 

LOL well there is that :) I was just thinking it would be nice if unRAID could give back to the larger Docker community too.  But it could be that this is a problem that Docker needs to solve rather than us.

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.