moby: Docker doesn't configure UTS namespace or /etc/hostname correctly
Edit: My assertion about setting domainname
may be suspect; see phemmer’s comment and discussion below. The issue of erroneously passing the FQDN to syscall.Sethostname
remains however.
Environment
vagrant@vagrant-ubuntu-utopic-64:~$ docker --version
Docker version 1.7.0, build 0baf609
Problem
Docker accepts a fully qualified domain name as the argument to --hostname
, and models separate Hostname
and Domainname
fields in runconfig.Config
; however once inside libcontainer only Hostname
is modelled, and this erroneously includes the domain name which is then fed into syscall.Sethostname
with the following results:
vagrant@vagrant-ubuntu-utopic-64:~$ docker run --hostname test.example.com -ti ubuntu
root@test:/# hostname
test.example.com
root@test:/# domainname
(none)
This is not correct; the value passed to syscall.Sethostname
should be the unqualified hostname, and the remainder to syscall.Setdomainname
. This would yield the expected output:
vagrant@vagrant-ubuntu-utopic-64:~$ docker run --hostname test.example.com -ti ubuntu
root@test:/# hostname
test
root@test:/# domainname
example.com
Currently, libcontainer does not invoke syscall.Setdomainname
at all, leaving the domain name parameter of the UTS namespace uninitialised.
Docker is also incorrectly generating an /etc/hostname
file with the fully qualified name - again this should be the unqualified name, and the FQDN set by aliasing in /etc/hosts
.
It could also be argued that --hostname
should be renamed to --fqdn
, or changed so that it admits only an unqualified name and companioned by a new --domainname
option to set the remainder.
Finally, the error message is uninformative:
docker run --hostname 012345678901234567890123456789012345678901234567890123456789.example.com -ti ubuntu
Error response from daemon: Cannot start container c1bb14c2a10b2341c185aed804ab6f625ca7a1164ea90ea4fd37ea56b6e2bed0: [8] System error: invalid argument
Consequences
- UTS namepsace not correctly initialised
- The underlying
sethostname
system call limits the hostname to 64 characters. Because Docker is calling it with the fully qualified name, the entire FQDN is limited to 64 characters (weaveworks/weave#1006)
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 19 (11 by maintainers)
I’m really confused then. If you don’t want a fully qualified hostname, then don’t pass a fully qualified hostname.