Docker Community Forums

Share and learn in the Docker community.

Docker Hostname (-h) doesn't fuly work on 1.9 (since 1.4)


(Sam) #1

Its been a while since I tested my docker setup (July 15). I need to get a specific hostname for this container from INSIDE the container. (the software running inside the container needs it).

anyhow, in 1.4 i used -h NEW_HOSTNAME and it was added, AND mapped to the IP address of the container (assigned by DHCP). now in 1.9 the hostname gets assigned, but if I try to use that hostname I get unknown host

sam@buildserver:~/Downloads/lisa/docker$ docker exec Dash1 hostname
VS-DASHBOARD
sam@buildserver:~/Downloads/lisa/docker$ docker exec Dash1 ping VS-DASHBOARD
ping: unknown host VS-DASHBOARD

the hostname entry is NOT is the container /etc/hosts

what changed, is there a workaround? we will not know the IP address until after the container is running (assigned by DHCP), so the DockerFile run… approaches to fixing /etc/hosts won’t work .