Hey Rich,

nice idea, but unfortunately this provides the hostname of the container
itself.

$ docker run -ti -v /proc/sys/kernel/hostname:/etc/docker-hostname:ro nginx bash
root@bea048d42fc3:/# cat /etc/docker-hostname
bea048d42fc3
root@bea048d42fc3:/#

Without digging deep into it I reckon that the proc (and the sys)
filesystems are treated differently, to be sure that each container is in a
distinct /proc filesystem.

Cheers Christian




On 23 August 2016 at 12:01:49, Rich Freeman (ri...@gentoo.org) wrote:

On Tue, Aug 23, 2016 at 2:39 AM, Daniel Campbell <z...@gentoo.org> wrote:
>
> 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
>

Seems to me that symlinking /proc/sys/kernel/hostname would be
simpler. Also, more reliable, because there are other ways the
hostname could be set other than from /etc/conf.d/hostname. The
hostname can also change.

-- 
Rich

Reply via email to