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