title: Is there any way to flush the docker DNS cache (internal)?
body: <p>I'm using Docker <code>18.03.1-ce</code> and if I create a container, remove it and then re-create it, the internal DNS retains the old address (in addition to the new). </p>
  
  <p>Is there any way to clear or flush the old entries? If I delete and re-create the network then that flushes it but I don't want to have to do that every time.</p>
  
  <p>I create the network:</p>
  
  <pre><code>docker network create -d overlay --attachable --subnet 10.0.0.0/24 --gateway 10.0.0.1 --scope swarm -o parent=ens224 overlay1
  </code></pre>
  
  <p>Then create a container (SQL for this example)</p>
  
  <pre><code>docker container run -d --rm --network overlay1 --name sql -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=Some_SA_Passw0rd' -p 1433:1433 microsoft/mssql-server-linux 
  </code></pre>
  
  <p>If I create an Alpine container on the same network I can <code>nslookup sql</code> by name and it resolves to <code>10.0.0.6</code>. No problems, so far-so-good.</p>
  
  <p>Now, if I remove the SQL container and re-create it then <code>nslookup sql</code> shows <code>10.0.0.6</code> and <code>10.0.0.8</code>. The <code>10.0.0.6</code> is the old address and no longer alive but still resolves.</p>
  
  <p>The nameserver my containers are using is <code>127.0.0.11</code> which is typical for a user-created network but I haven't been able to find anything that will let me clear its cache. </p>
  
  <p>Maybe I'm missing something but I had assumed the DNS entries would be torn down whenever the containers get removed. </p>
  
  <p>Any insight is certainly appreciated! </p>