@@ -108,6 +108,11 @@ func (c *container) PID() int {
108108
109109func (c * container ) Hostname () string {
110110 if c .container .Config .Domainname == "" {
111+ // If hostname isn't set on a container it defaults to a random hex
112+ // number which we don't want to show in the UI.
113+ if strings .HasPrefix (c .container .ID , c .container .Config .Hostname ) {
114+ return ""
115+ }
111116 return c .container .Config .Hostname
112117 }
113118
@@ -376,12 +381,14 @@ func (c *container) getSanitizedCommand() string {
376381
377382func (c * container ) getBaseNode () report.Node {
378383 result := report .MakeNodeWith (report .MakeContainerNodeID (c .ID ()), map [string ]string {
379- ContainerID : c .ID (),
380- ContainerCreated : c .container .Created .Format (time .RFC3339Nano ),
381- ContainerCommand : c .getSanitizedCommand (),
382- ImageID : c .Image (),
383- ContainerHostname : c .Hostname (),
384+ ContainerID : c .ID (),
385+ ContainerCreated : c .container .Created .Format (time .RFC3339Nano ),
386+ ContainerCommand : c .getSanitizedCommand (),
387+ ImageID : c .Image (),
384388 }).WithParent (report .ContainerImage , report .MakeContainerImageNodeID (c .Image ()))
389+ if hostname := c .Hostname (); hostname != "" {
390+ result = result .WithLatest (ContainerHostname , hostname )
391+ }
385392 result = result .AddPrefixPropertyList (LabelPrefix , c .container .Config .Labels )
386393 if ! c .noEnvironmentVariables {
387394 result = result .AddPrefixPropertyList (EnvPrefix , c .env ())
0 commit comments