Description
Run a container by docker run and specify a FQDN hostname.
$ docker run -it --rm --hostname wombat.example.com ubuntu bash
root@wombat:/# cat /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.2 wombat.example.com
root@wombat:/# hostname
wombat.example.com
root@wombat:/# hostname -d
example.com
root@wombat:/# hostname -s
wombat
root@wombat:/# cat /etc/hostname
wombat.example.com
root@wombat:/#
Describe the results you received:
As the result showed above, the hostname related entry is:
172.17.0.2 wombat.example.com
Describe the results you expected:
172.17.0.2 wombat.example.com wombat
If I understand #20200 and moby/libnetwork#950 correctly, the --hostname wombat.example.com will directly pass wombat.example.com to backend without splitting, and in backend libnetwork/etchosts/etchosts.go will split the FQDN hostname to get the first part, unqualified name, and write both FQDN and unqualified name to /etc/hosts.
This is the code from https://github.com/docker/libnetwork/blob/master/etchosts/etchosts.go:
//set main record
var mainRec Record
mainRec.IP = IP
// User might have provided a FQDN in hostname or split it across hostname
// and domainname. We want the FQDN and the bare hostname.
fqdn := hostname
if domainname != "" {
fqdn = fmt.Sprintf("%s.%s", fqdn, domainname)
}
parts := strings.SplitN(fqdn, ".", 2)
if len(parts) == 2 {
mainRec.Hosts = fmt.Sprintf("%s %s", fqdn, parts[0])
} else {
mainRec.Hosts = fqdn
}
if _, err := mainRec.WriteTo(content); err != nil {
return err
}
However, the result is different from my understanding, the wombat part is missing.
Output of docker version:
$ docker version
Client:
Version: 1.12.3
API version: 1.24
Go version: go1.6.3
Git commit: 6b644ec
Built: Wed Oct 26 22:01:48 2016
OS/Arch: linux/amd64
Server:
Version: 1.12.3
API version: 1.24
Go version: go1.6.3
Git commit: 6b644ec
Built: Wed Oct 26 22:01:48 2016
OS/Arch: linux/amd64
Output of docker info:
$ docker info
Containers: 3
Running: 1
Paused: 0
Stopped: 2
Images: 1
Server Version: 1.12.3
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 11
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: null bridge host overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: apparmor seccomp
Kernel Version: 4.4.0-51-generic
Operating System: Ubuntu 16.04.1 LTS
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 488.5 MiB
Name: d1
ID: 4JWN:U3QN:DXET:W2BC:6GD7:4IRO:YOUV:XW2C:ETA3:CIAC:EUDZ:V7DQ
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 23
Goroutines: 37
System Time: 2016-12-03T13:38:05.442543074Z
EventsListeners: 0
Registry: https://index.docker.io/v1/
WARNING: No swap limit support
Labels:
provider=digitalocean
Insecure Registries:
127.0.0.0/8
Additional environment details (AWS, VirtualBox, physical, etc.):
I tested this on Digital Ocean droplet, Virtualbox Boot2docker and Docker for Mac, they are same result.
Description
Run a container by
docker runand specify a FQDN hostname.Describe the results you received:
As the result showed above, the hostname related entry is:
Describe the results you expected:
If I understand #20200 and moby/libnetwork#950 correctly, the
--hostname wombat.example.comwill directly passwombat.example.comto backend without splitting, and in backendlibnetwork/etchosts/etchosts.gowill split the FQDN hostname to get the first part, unqualified name, and write both FQDN and unqualified name to/etc/hosts.This is the code from https://github.com/docker/libnetwork/blob/master/etchosts/etchosts.go:
However, the result is different from my understanding, the
wombatpart is missing.Output of
docker version:Output of
docker info:Additional environment details (AWS, VirtualBox, physical, etc.):
I tested this on Digital Ocean droplet, Virtualbox Boot2docker and Docker for Mac, they are same result.