# Setting domainname differs from Docker - SOLVED

**URL:** <https://forums.suse.com/t/setting-domainname-differs-from-docker-solved/11817>\
**Category:** Rancher 1.x\
**Created:** [September 21, 2018, 10:37am UTC](https://forums.suse.com/t/setting-domainname-differs-from-docker-solved/11817 "2018-09-21T10:37:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kevin\_Thorpe](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/kevin_thorpe/32/5665_2.png) [@Kevin\_Thorpe](https://forums.suse.com/u/Kevin_Thorpe)\
**Post date:** [September 21, 2018, 10:37am UTC](https://forums.suse.com/t/setting-domainname-differs-from-docker-solved/11817/1 "2018-09-21T10:37:33Z")

</div>

I have a quick question about setting the domainname in Rancher. The behaviour differs from Docker native and I don’t know how.

We have a java program that is licenced and the licence is tied to the hostname being in our domain.This is packaged as a docker container and deployed using the domainname parameter to ensure that the container hostname is [whatever.ourdomain.com](http://whatever.ourdomain.com). This appears to work as the hostname in bash in the entrypoint shell script and also in an exec shell is indeed in [ourdomain.com](http://ourdomain.com). However when deployedin Rancher the Java program is reading the hostname without a domain at all. Starting the exact same container on the same docker host using docker-compose instead of rancher-compose and the same docker-compose.yml actually works. There’s obviously a slight difference in how the domainname parameter is handled in rancher-compose and docker-compose.

Rancher v1.6.21  
Rancher-compose v0.12.5

---

<div class="post-metadata">

**Author:** ![Kevin\_Thorpe](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/kevin_thorpe/32/5665_2.png) [@Kevin\_Thorpe](https://forums.suse.com/u/Kevin_Thorpe)\
**Post date:** [September 21, 2018, 3:02pm UTC](https://forums.suse.com/t/setting-domainname-differs-from-docker-solved/11817/2 "2018-09-21T15:02:30Z")

</div>

TLDR: Rancher doesn’t add hostname.comainname to /etc/hosts

This is an oddity in Java. In there you use the following line to get your hostname `InetAddress.getLocalHost().getHostName()`. This appears for some unknown reason to have multiple implementations. A trivial `hostname` program in Java gets the name and domain correctly without looking at /etc/hosts. For some reason the same call in the licenced program is reading /etc/hosts. Adding the do9main name in /etc/hosts fixes things.

Next problem is that sed can’t edit /etc/hosts in a container as you can’t change the inode as it’s imported.
