Add a host name to /etc/hosts?

264 views
Skip to first unread message

Derek Mahar

unread,
Jul 8, 2016, 8:27:28 PM7/8/16
to CoreOS Dev
How can I instruct 'rkt run' to add a particular host name (for example, that specified in '--hostname') to "/etc/hosts" inside the container?  https://github.com/kubernetes/kubernetes/issues/26102 discusses this issue and others, but much of the discussion I don't understand.

Thank you,

Derek

Jonathan Boulle

unread,
Jul 11, 2016, 5:18:10 AM7/11/16
to coreo...@googlegroups.com
What version of rkt are you using? I believe this was fixed in https://github.com/coreos/rkt/pull/2761 which landed in 1.9.0

Alban Crequy

unread,
Jul 11, 2016, 5:25:29 AM7/11/16
to coreo...@googlegroups.com
https://github.com/coreos/rkt/pull/2761 was about /etc/hostname and
not /etc/hosts. So that's not helping for adding more entries in
/etc/hosts.

Jonathan Boulle

unread,
Jul 11, 2016, 5:44:04 AM7/11/16
to coreo...@googlegroups.com
Sorry, I guess I was confused, and https://github.com/coreos/rkt/issues/2223 is probably a better one to look at

Derek Mahar

unread,
Jul 11, 2016, 1:23:58 PM7/11/16
to CoreOS Dev
https://github.com/coreos/rkt/issues/2223 is an open issue, so I guess adding a host name to /etc/hosts in a container is still a work in progress.

Florian Koch

unread,
Jul 11, 2016, 1:33:36 PM7/11/16
to coreo...@googlegroups.com
if you remove /etc/hosts from your image , rkt generates a new one and
adds the hostname

Derek Mahar

unread,
Jul 11, 2016, 2:52:45 PM7/11/16
to CoreOS Dev
Which version will add the host name to /etc/hosts?  I just ran rkt 1.9.1 after moving /etc/hosts and rkt didn't recreate this file.

Florian Koch

unread,
Jul 11, 2016, 3:37:06 PM7/11/16
to coreo...@googlegroups.com
hm you are right.... if I'm not mistaken it was fixed in 1.6 or so

Florian Koch

unread,
Jul 11, 2016, 3:45:43 PM7/11/16
to coreo...@googlegroups.com
ok with rkt 1.10 it does work

/opt/rkt/rkt --insecure-options=all run --interactive
aci.example.net/centos:latest --exec=/bin/bash
image: using image from local store for image name
coreos.com/rkt/stage1-coreos:1.7.0
image: searching for app image aci.example.net/centos
image: remote fetching from URL
"http://aci.example.net/centos-latest-linux-amd64.aci"
Downloading ACI: [=============================================] 70.6 MB/70.6 MB
networking: loading networks from /etc/rkt/net.d
networking: loading network default with type ptp
19:44:04 INFO d/b/template/file.go:74 Templating file
dst=//etc/yum/yum.conf
src=/dgr/templates/etc/yum/yum.conf.tmpl
bash-4.2# cat /etc/hosts
127.0.0.1 rkt-b04d1433-12a7-4a5d-b4c3-07848238adbc
localhost localhost.localdomain
bash-4.2#
Reply all
Reply to author
Forward
0 new messages