<p>I want to set the hostname in a container running inside Kubernetes, but Kubernetes appears to be overriding whatever I set at runtime.</p>

<p>I've tried both setting /etc/hostname in the docker image I'm having Kubernetes use, and including <code>echo "host.example.com &gt; /etc/hostname"</code> in the CMD in the Dockerfile.</p>

<p>There appears to be a docker flag <code>-h</code> to set the hostname. Is there a way for me to specify in my replication controller that it should start the container with a special flag?</p>

<p>The container's Debian, if it helps.</p>

<p>My previous answer was incorrect, edited with correct info</p>

<p>The <code>-h</code> flag for <code>docker run</code> will set the hostname of the container when you create it.</p>

<p>Test it out: <code>docker run -h test.example.com -it ubuntu /bin/bash</code></p>

<p>The <code>docker start</code> command does not have the same <code>-h</code> or <code>--hostname</code> argument though. It doesn't seem possible to change the hostname of an existing container, just a new one from an image.</p>

<p>However w/r/t Kubernetes: There is an open <a href="https://github.com/GoogleCloudPlatform/kubernetes/issues/4825" rel="noreferrer">issue on Github</a> regarding how Kubernetes handles hostnames.  It does not seem like Kubernetes exposes docker's hostname setting directly, but you might be able to influence it via your pod name</p>
