# Allow hostname in PeerAddress entries?

**URL:** https://forum.pydio.com/t/allow-hostname-in-peeraddress-entries/2099
**Category:** Pydio Cells
**Created:** [February 3, 2019, 2:29am UTC](https://forum.pydio.com/t/allow-hostname-in-peeraddress-entries/2099 "2019-02-03T02:29:46Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![geoff](https://avatars.discourse-cdn.com/v4/letter/g/a3d4f5/32.png) [@geoff](https://forum.pydio.com/u/geoff)
#### Post date: [February 3, 2019, 2:29am UTC](https://forum.pydio.com/t/allow-hostname-in-peeraddress-entries/2099/1 "2019-02-03T02:29:46Z")

</div>

Is there some reason we can’t specify a hostname instead of an IP for the `PeerAddress` entries in the config file? If the reason is just that it hasn’t been done, is there any reason I shouldn’t log a feature request?

I’m struggling with this same issue of the IP changing each time described in [this thread](https://forum.pydio.com/t/solved-services-stopped-using-docker/1995/15), but docker doesn’t allow static IPs when running in swarm mode.

I modified the above solution from @kvaps at the end of that thread to try to do the same thing, since it seems like a sensible workaround; unfortunately, I can’t see how to get the container IP in the docker compose file. I tried this:

`command: ['/bin/sh', '-c', 'IP=$$(hostname -i); sed -i "/PeerAddress/ s/: .*/: \"$IP\",/g" /root/.config/pydio/cells/pydio.json; exec /bin/docker-entrypoint.sh cells start']`

…but `hostname -i` always resolves to `127.0.0.1`, which doesn’t work.

---

<div class="post-metadata">

### Author: ![rossbeazley](https://yyz2.discourse-cdn.com/flex032/user_avatar/forum.pydio.com/rossbeazley/32/635_2.png) [@rossbeazley](https://forum.pydio.com/u/rossbeazley)
#### Post date: [February 3, 2019, 9:40am UTC](https://forum.pydio.com/t/allow-hostname-in-peeraddress-entries/2099/2 "2019-02-03T09:40:59Z")

</div>

Hi Geoff, i think the link may be to the wrong thread.

does ifconfig work for you in the container?

---

<div class="post-metadata">

### Author: ![geoff](https://avatars.discourse-cdn.com/v4/letter/g/a3d4f5/32.png) [@geoff](https://forum.pydio.com/u/geoff)
#### Post date: [February 3, 2019, 4:12pm UTC](https://forum.pydio.com/t/allow-hostname-in-peeraddress-entries/2099/3 "2019-02-03T16:12:19Z")

</div>

Thanks Ross - I fixed the link.

So, yes, I do get valid values in the container, and also once I’m in that context I do get a valid result from `hostname -i`; I also just figured out that the `127.0.0.1` is coming from a local environment variable, so there’s something else wrong with my shell line (not surprising!)

```
/pydio # ifconfig
eth0 Link encap:Ethernet HWaddr 02:42:0A:00:01:80
          inet addr:10.0.1.128 Bcast:10.0.1.255 Mask:255.255.255.0
          [...]
eth1 Link encap:Ethernet HWaddr 02:42:AC:14:00:07
          inet addr:172.20.0.7 Bcast:172.20.255.255 Mask:255.255.0.0
          [...]
lo Link encap:Local Loopback
          inet addr:127.0.0.1 Mask:255.0.0.0

/pydio # hostname -i
10.0.1.128

```

When I remove the environment variable, and one of the ‘`$`’ signs, I end up with this:

`command: ['/bin/sh', '-c', 'IP=$(hostname -i); sed -i "/PeerAddress/ s/: .*/: \"$IP\",/g" /root/.config/pydio/cells/pydio.json; exec /bin/docker-entrypoint.sh cells start']`

…resolving to this:

 ![image](https://canada1.discourse-cdn.com/flex032/uploads/pydio/original/1X/e9eb240cdf1e3bcb03c4290f7ae248fdffab1de1.png)

Maybe it’s just a bad shell line? Or perhaps the hostname command doesn’t resolve at that early stage?

---

<div class="post-metadata">

### Author: ![rossbeazley](https://yyz2.discourse-cdn.com/flex032/user_avatar/forum.pydio.com/rossbeazley/32/635_2.png) [@rossbeazley](https://forum.pydio.com/u/rossbeazley)
#### Post date: [February 3, 2019, 7:30pm UTC](https://forum.pydio.com/t/allow-hostname-in-peeraddress-entries/2099/4 "2019-02-03T19:30:39Z")

</div>

it looks like the subshell you are using does get run on the host not the container, see here: [https://serverfault.com/questions/782967/docker-exec-run-shell-command-nesting](https://serverfault.com/questions/782967/docker-exec-run-shell-command-nesting)

---

<div class="post-metadata">

### Author: ![rossbeazley](https://yyz2.discourse-cdn.com/flex032/user_avatar/forum.pydio.com/rossbeazley/32/635_2.png) [@rossbeazley](https://forum.pydio.com/u/rossbeazley)
#### Post date: [February 3, 2019, 7:32pm UTC](https://forum.pydio.com/t/allow-hostname-in-peeraddress-entries/2099/5 "2019-02-03T19:32:55Z")

</div>

maybe using xargs or something might get what you want? or maybe backtics?

---

<div class="post-metadata">

### Author: ![geoff](https://avatars.discourse-cdn.com/v4/letter/g/a3d4f5/32.png) [@geoff](https://forum.pydio.com/u/geoff)
#### Post date: [February 3, 2019, 10:50pm UTC](https://forum.pydio.com/t/allow-hostname-in-peeraddress-entries/2099/6 "2019-02-03T22:50:26Z")

</div>

Ross, thanks so much for the tip on the backticks, my shell knowledge is still so basic!

Once I had that I still needed to find a command that would happily sit in the overall command line - generally it seems quite tricky to work around the constraints of the docker compose format. For example, nested quotes are hard to work around, and dollar signs seem to be problematic.

I noticed that the last entry in `hosts` is for the container, so in combination with your backticks suggstion I managed to put together a command that extracts this without any quotes or dollar signs:

```
echo `tail -1 /etc/hosts | cut -f 1` > /home/ip.txt

```

Then, embedding that into my overall command line:

```
command: ['/bin/sh', '-c', 'echo `tail -1 /etc/hosts | cut -f 1` > /home/ip.txt; sed -i "/PeerAddress/ s/: .*/: \"`cat /home/ip.txt`\",/g" /root/.config/pydio/cells/pydio.json; exec /bin/docker-entrypoint.sh cells start']

```

…which in turn gives me a correct IP:

```
"pydio.grpc.data.index.personal": {
  "PeerAddress": "10.0.1.235",
  "dsn": "default",

```

Thanks again! I’d still really like to be able to use the hostname in the file in the first place, so I have logged a feature request for this.

Cheers,  
Geoff

---

<div class="post-metadata">

### Author: ![geoff](https://avatars.discourse-cdn.com/v4/letter/g/a3d4f5/32.png) [@geoff](https://forum.pydio.com/u/geoff)
#### Post date: [March 3, 2019, 6:50pm UTC](https://forum.pydio.com/t/allow-hostname-in-peeraddress-entries/2099/7 "2019-03-03T18:50:04Z")

</div>

@charles I see you committed a change to support this - thanks! Any idea when you’ll be updating the `pydio/cells:unstable` docker image?

Cheers,  
Geoff

---

<div class="post-metadata">

### Author: ![charles](https://yyz2.discourse-cdn.com/flex032/user_avatar/forum.pydio.com/charles/32/3_2.png) [@charles](https://forum.pydio.com/u/charles)
#### Post date: [March 4, 2019, 7:43am UTC](https://forum.pydio.com/t/allow-hostname-in-peeraddress-entries/2099/8 "2019-03-04T07:43:18Z")

</div>

hi geoff, you’re too fast 🙂 . Not hardly tested yet, give us a couple of days…

---

<div class="post-metadata">

### Author: ![geoff](https://avatars.discourse-cdn.com/v4/letter/g/a3d4f5/32.png) [@geoff](https://forum.pydio.com/u/geoff)
#### Post date: [March 4, 2019, 2:16pm UTC](https://forum.pydio.com/t/allow-hostname-in-peeraddress-entries/2099/9 "2019-03-04T14:16:31Z")

</div>

Haha - thanks Charles! Was just a coincidence that I happened to check and see the commit.

I’m hoping it may help with the general behind-a-proxy connectivity? Happy to test it either way and see.

---

<div class="post-metadata">

### Author: ![charles](https://yyz2.discourse-cdn.com/flex032/user_avatar/forum.pydio.com/charles/32/3_2.png) [@charles](https://forum.pydio.com/u/charles)
#### Post date: [March 4, 2019, 3:50pm UTC](https://forum.pydio.com/t/allow-hostname-in-peeraddress-entries/2099/10 "2019-03-04T15:50:10Z")

</div>

you can test now if you like!

---

<div class="post-metadata">

### Author: ![geoff](https://avatars.discourse-cdn.com/v4/letter/g/a3d4f5/32.png) [@geoff](https://forum.pydio.com/u/geoff)
#### Post date: [March 5, 2019, 9:02pm UTC](https://forum.pydio.com/t/allow-hostname-in-peeraddress-entries/2099/11 "2019-03-05T21:02:03Z")

</div>

thanks - will do! Will bump it and see how it goes.

---

<div class="post-metadata">

### Author: ![geoff](https://avatars.discourse-cdn.com/v4/letter/g/a3d4f5/32.png) [@geoff](https://forum.pydio.com/u/geoff)
#### Post date: [March 6, 2019, 1:10am UTC](https://forum.pydio.com/t/allow-hostname-in-peeraddress-entries/2099/12 "2019-03-06T01:10:29Z")

</div>

Ok, so it’s still not working for me. Possibly I have the wrong image, but I’m pretty sure I managed to force the update: how can I check from inside the GUI? The about box says “Details about version, licensing […]” but I don’t see any version in there.

The upgrade page says 1.4.0, with a revision of:  
`Revision : c78c2462f8231b065687031ff62c3b273d6c4dca`

When I start the container, it gives me:

```
2019-03-06T01:02:01.833Z	INFO	pydio.grpc.data.objects	Ignoring pydio.grpc.data.objects.local1 as PeerAddress (cells) does not correspond to any current peer ip

```

…but when I shell into the container and `ping cells` I get valid results.  
Any suggestions?

---

<div class="post-metadata">

### Author: ![geoff](https://avatars.discourse-cdn.com/v4/letter/g/a3d4f5/32.png) [@geoff](https://forum.pydio.com/u/geoff)
#### Post date: [March 6, 2019, 3:12am UTC](https://forum.pydio.com/t/allow-hostname-in-peeraddress-entries/2099/13 "2019-03-06T03:12:59Z")

</div>

Wait - I spoke too soon, I was still using the `unstable` image. Switching to the `pre-release` image sorted it! Thanks!

I still don’t have a working ability to login due to all the other reverse proxy images, but it’s nice to have one part sorted out.

---

<div class="post-metadata">

### Author: ![rckalex](https://avatars.discourse-cdn.com/v4/letter/r/a88e57/32.png) [@rckalex](https://forum.pydio.com/u/rckalex)
#### Post date: [August 27, 2020, 10:28pm UTC](https://forum.pydio.com/t/allow-hostname-in-peeraddress-entries/2099/14 "2020-08-27T22:28:49Z")

</div>

@charles Hi Charles,

I tore down and created a new instance today and see that the hostname entered into the database configuration step of the setup process was saved in the “databases” entry of the json. However, further down “PeerAddress” entries for all the datasources appear to use the resolved IP address.

Is it safe to replace those with the hostname?

---

<div class="post-metadata">

### Author: ![zayn](https://avatars.discourse-cdn.com/v4/letter/z/a87d85/32.png) [@zayn](https://forum.pydio.com/u/zayn)
#### Post date: [August 31, 2020, 9:53am UTC](https://forum.pydio.com/t/allow-hostname-in-peeraddress-entries/2099/15 "2020-08-31T09:53:38Z")

</div>

Hello @rckalex,

If you are using the recent version for Pydio Cells, you should now be able to bind the datasource with any peerAddress, we now use both the hostname and ip.
