# Hostname not set in metadata service

**URL:** <https://forums.suse.com/t/hostname-not-set-in-metadata-service/2567>\
**Category:** Rancher 1.x\
**Created:** [April 22, 2016, 12:10pm UTC](https://forums.suse.com/t/hostname-not-set-in-metadata-service/2567 "2016-04-22T12:10:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexR](https://avatars.discourse-cdn.com/v4/letter/a/8dc957/32.png) [@alexR](https://forums.suse.com/u/alexR)\
**Post date:** [April 22, 2016, 12:10pm UTC](https://forums.suse.com/t/hostname-not-set-in-metadata-service/2567/1 "2016-04-22T12:10:53Z")

</div>

Hello everyone,

I am trying the metadata service, but for some reason it seems the hostname is not set in the returned JSON (I am using JSON). I get something like this

````auto
  'health_state': None,
  'host_uuid': '89d17a73-fa31-4c53-80fe-fbdbea0161fd',
  'hostname': None,
  'ips': ['10.42.98.113'],
  'labels': {'io.rancher.container.hostname_override': 'container_name',
             'io.rancher.project.name': 'elasticsearch',
             'io.rancher.project_service.name': 'elasticsearch/elasticsearch-datanodes',
             'io.rancher.scheduler.affinity:container_label_ne': 'io.rancher.stack_service.name=${stack_name}/${service_name}',
             'io.rancher.scheduler.affinity:container_label_soft': 'io.rancher.service.deployment.unit=fc594957-cc1e-46d6-b860-15cec4956048',
             'io.rancher.service.deployment.unit': 'fc594957-cc1e-46d6-b860-15cec4956048',
             'io.rancher.service.hash': '3be4d2cccf8e55516b278adeeba638ffeb44059b',
             'io.rancher.service.launch.config': 'io.rancher.service.primary.launch.config',
             'io.rancher.sidekicks': 'elasticsearch-base-datanode,elasticsearch-datavolume-datanode',
             'io.rancher.stack.name': 'elasticsearch',
             'io.rancher.stack_service.name': 'elasticsearch/elasticsearch-datanodes'},
  'name': 'elasticsearch_elasticsearch-datanodes_1',
  'ports': [],
  'primary_ip': '10.42.98.113',
  'service_index': '1',
  'service_name': 'elasticsearch-datanodes',
  'stack_name': 'elasticsearch',
  'start_count': 1,
  'uuid': '2c7e8b1d-1e7c-44a7-8422-0ac28d4eb5c6'},```

Also, I am assuming this *hostname* and *host_uui* would correspond the one of the hardware host running this container, is this assumption right? 

Is there something I need to do to get the hostname in the response?

I am using /latest as metadata endpoint.

Best regards,

Alejandro
````

---

<div class="post-metadata">

**Author:** ![denise](https://avatars.discourse-cdn.com/v4/letter/d/82dd89/32.png) [@denise](https://forums.suse.com/u/denise)\
**Post date:** [April 30, 2016, 4:15am UTC](https://forums.suse.com/t/hostname-not-set-in-metadata-service/2567/2 "2016-04-30T04:15:26Z")

</div>

It looks like there is a bug where the hostname in the metadata is not showing up if it is set in the container, but by default, the hostname in the container is not set unless you select an option in the UI.

 ![](https://us1.discourse-cdn.com/flex022/uploads/suse/original/2X/4/42d23f16845ca3110012164ac00374b0987a0046.png)

> <https://github.com/rancher/rancher/issues/4626>
>
> Rancher Version:
> v1.1.0-dev1
> 
> Docker Version:
> 1.10.3
> 
> OS: 
> Ubuntu 14.04
> 
> Steps t…o Reproduce: 
> 1. Create a service and select "Use the container name" for hostname
> 2. Exec into the container and run \`curl --header 'Accept: application/json' 'http://rancher-metadata/2015-12-19/self/container'\`
> 
> Results: 
> The hostname is set in the API, but the hostname is not in the metadata. 
> 
> Expected:
> If the hostname is set in the API, the metadata should have the hostname.

---

<div class="post-metadata">

**Author:** ![alexR](https://avatars.discourse-cdn.com/v4/letter/a/8dc957/32.png) [@alexR](https://forums.suse.com/u/alexR)\
**Post date:** [May 2, 2016, 7:09am UTC](https://forums.suse.com/t/hostname-not-set-in-metadata-service/2567/3 "2016-05-02T07:09:13Z")

</div>

Thanks for the reply Denise,

I was wondering is there a way to get the “hardware” hostname in the metadata.

Cheers,

Alejandro

---

<div class="post-metadata">

**Author:** ![denise](https://avatars.discourse-cdn.com/v4/letter/d/82dd89/32.png) [@denise](https://forums.suse.com/u/denise)\
**Post date:** [May 6, 2016, 4:45am UTC](https://forums.suse.com/t/hostname-not-set-in-metadata-service/2567/4 "2016-05-06T04:45:07Z")

</div>

Unfortunately, no, there is no way to get the hardware hostname.
