title: How to edit /etc/host in Docker image from jenkins pipeline
body: <p>I have problem and not sure how to solve this. I have a jenkis pipeline which creates a Azure container instance with some images that are pushed (on same pipeline) to a Azure registry. Now I need a docker container image to be pushed on registry but with a modification on the /etc/hosts file. 
   I tried with:</p>
  
  <pre><code>RUN  sed -i '$ a 172.x.x.x  host.domain.com ' /etc/hosts
  </code></pre>
  
  <p>and</p>
  
  <pre><code>RUN echo &gt;&gt; 172.x.x.x  host.domain.com /etc/hosts
  </code></pre>
  
  <p>And in pipleine I get error: </p>
  
  <pre><code>1msed: can't move '/etc/hostsJCkFPo' to '/etc/hosts': Resource busy
  </code></pre>
  
  <p>I red that I can´t do such thing during build phase manually,  so I search and I looked into,  that using "</p>
  
  <blockquote>
    <p>--add-host</p>
  </blockquote>
  
  <p>" you can achieve this.
  Thing is that I don´t know how can I do this in jenkins file. I tried with following inside jenkins file (adding just part of docker build):</p>
  
  <pre><code> def imageNametom = 'repo.azurecr.io/container-tomcat'
   def imageNameTagged = imageNametom + ':' + env.BUILD_NUMBER
  
   docker.build("${imageNameTagged}" , "--add-host=host.domain.com:172.x.x.x").
  </code></pre>
  
  <p>but I get following error:</p>
  
  <pre><code>docker build -t repo.azurecr.io/container-tomcat:6 --add-host=host.domain.com:172.x.x.x
  invalid argument "host.domain.com" for "--add-host" flag: bad format for add-host: "host.domain.com"
  </code></pre>
  
  <p>How Can I add this into /etc/hosts file? so containers created from that image they all have this hosts file.?</p>
  
  <p>thank you</p>