Hey y’all, just to elaborate on the problem and clear up the fuzz I made. I am facing to be distro-agnostic, thus I do not know in advance if I am running on DockerForMac (which uses Alpine Linux), some weird Ubuntu vagrant setup of mine or a fleet of gentoo hosts. Docker Service schedules the service as it pleases (oversimplification). For services I fancy using global services in which the described services is started on each node of the SWAM cluster. A demo of how this looks like (fast-forward to minute 28): https://www.youtube.com/watch?v=g-YNST-COdI I have four nodes in my cluster: ### docker node ls ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS 4iffi5tt5jlk03ub7nd7cf5r2 gentoo1 Ready Active 5m0x0vqtjugkwi13gkaa4ijk2 gentoo2 Ready Active 6eu0fiz0ch8e7pnbbzh8pj545 gentoo3 Ready Active Leader ckrxwdppbehyz806o7gxgashl * gentoo4 Ready Active Reachable $ ### If I use an environment variable like this: ### $ docker service create --name nginx --mode=global -e SERVICE_HOSTNAME=$(hostname -f) nginx ### Each of the tasks (a container to-be-run on one of the nodes) will now find an environment variable SERVICE_HOSTNAME, but it will a) be the same among all containers and b) it will show the hostname from which the service was created. Therefore environment variables are not going to get me far. On docker host with non-gentoo I can just run this (e.g. on my DockerForMac): ### $ docker service create --mount type=bind,source=/etc/hostname,target=/etc/docker-hostname:ro --name nginx nginx ### By doing so I am able to determine on which host I am running on each tasks without much hassle. ### $ docker exec -ti 56e8b2eaecc3 cat /etc/docker-hostname ### I am using this for a zookeeper service which should reuse the same MYID when restarted on a given node. Otherwise I would end up with a restarting container on a given node, which would get himself a new MYID and after a couple of restarts I am out of the range of MYID (up to 255). Cheers and again, sorry for the misunderstanding Christian > On 23 Aug 2016, at 08:39, Daniel Campbell wrote: > > On 08/22/2016 03:09 PM, William Hubbs wrote: >> On Mon, Aug 22, 2016 at 09:28:44PM +0200, Hans de Graaff wrote: >>> On Mon, 2016-08-22 at 10:58 -0500, William Hubbs wrote: >>>> All, >>>> >>>> it looks like app-emulation/docker expects /etc/hostname to exist. >>> >>> Is there a bug for this? docker seems to work fine for me on a system >>> without this file present. >> >> Ok, now for the clarification. >> >> Someone here at the office was wanting a cross-platform way to find out >> the hostname of the host the container is running on inside the >> container. We made another suggestion for that, so forget about the >> docker angle on this for now. >> >> But, /etc/hostname is a multi-distro standard for where the hostname is >> located, so I would like to make openrc prefer it over the setting in >> /etc/conf.d/hostname if it exists.A >> >> I suppose whether we populate it by default might be a separate >> question. >> >> William >> > Changing the way one configures the hostname because one or a few > packages A) need this knowledge, and B) hardcode /etc/hostname is not > worth changing the canonical way to update it and getting people to > change their habits. > > It makes a bit more sense to rely on previous configuration > (/etc/conf.d/hostname) and write a tiny 'script' that populates > /etc/hostname. bash could do it (naively) in two lines: > > source /etc/conf.d/hostname > echo "$hostname" > /etc/hostname > > The 'multi-distro standard' is du jour at best and imo not a compelling > reason to follow. > > -- > Daniel Campbell - Gentoo Developer > OpenPGP Key: 0x1EA055D6 @ hkp://keys.gnupg.net > fpr: AE03 9064 AE00 053C 270C 1DE4 6F7A 9091 1EA0 55D6 >