From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 50A2F138330 for ; Tue, 23 Aug 2016 12:33:50 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id ADDA521C098; Tue, 23 Aug 2016 12:33:41 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 7FAEBE0B96 for ; Tue, 23 Aug 2016 12:33:40 +0000 (UTC) Received: from [192.168.1.100] (c-98-218-46-55.hsd1.md.comcast.net [98.218.46.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mjo) by smtp.gentoo.org (Postfix) with ESMTPSA id 9978934072E for ; Tue, 23 Aug 2016 12:33:39 +0000 (UTC) Subject: Re: [gentoo-dev] rfc: /etc/hostname on gentoo To: gentoo-dev@lists.gentoo.org References: <20160822155808.GA16219@whubbs1.gaikai.biz> <1471894124.32381.0.camel@gentoo.org> <20160822220925.GB18116@whubbs1.gaikai.biz> From: Michael Orlitzky Message-ID: <2f53ede5-d991-96fb-f42f-938762a241b1@gentoo.org> Date: Tue, 23 Aug 2016 08:33:37 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Archives-Salt: f021cc57-3034-4fe2-916d-9f3c4160596a X-Archives-Hash: b4f96a7672bdbb3f14f272dd6a6b36a3 My mental model is wrong so I'm probably about to say something stupid. I'm not familiar with the way docker works so bear with me... On 08/23/2016 03:01 AM, Christian Kniep wrote: > > ### > $ docker service create --name nginx --mode=global -e SERVICE_HOSTNAME=$(hostname -f) nginx > ### This looks like it would set the SERVICE_HOSTNAME environment variable inside the container to the hostname that you're running the command on. > 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. > Cool, I'm not confused yet. > 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 Doesn't this mount the /etc/hostname file, from the host that you run the command on, to the /etc/docker-hostname file within the container? If so, it would have the same problem as the environment variable, so it's got to be doing something else. ...Is it the other way around? Does it mount /etc/hostname from the container somewhere on the outside? > 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 > If this runs *inside* the container, then instead of using "cat" on a file, why not just run "hostname"? That should give you the hostname of the machine it ran on. For example, docker exec -ti 56e8b2eaecc3 hostname But, if that runs outside the container, then... I need a better understanding of what's going on before I start throwing out ideas.