Allow hostname in PeerAddress entries?

#1

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, 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.

#2

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

does ifconfig work for you in the container?

#3

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:

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

#4

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

#5

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

#6

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

#7

@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

#8

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

#9

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.

#10

you can test now if you like!

#11

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

#12

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?

#13

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.