Setting domainname differs from Docker - SOLVED

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 This appears to work as the hostname in bash in the entrypoint shell script and also in an exec shell is indeed in 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

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.