title: How to add my container's hostname to /etc/hosts?
body: <p>In order to support some old software solutions, I need to bind my container's <code>hostname</code> to <code>127.0.0.1</code>, leaving me with something like this:</p>
  
  <pre><code>$ hostname
  4e84a7ae5f92
  $ cat /etc/hosts | grep 127.0.0.1
  127.0.0.1       localhost 4e84a7ae5f92
  </code></pre>
  
  <p>Best case scenario would be to do in the Dockerfile, but since <code>docker build</code> builds an image (and not a container), it doesn't seem realistic.<br>
  Also if I try to do it with <code>sed</code> in the running container, I end up with an error:</p>
  
  <pre><code>$ sed -i '/^127\.0\.0\.1.*/ s/$/ '$(hostname)'/' /etc/hosts
  sed: cannot rename /etc/sedC5PkA2: Device or resource busy
  </code></pre>
  
  <p>What can I do ?</p>