title: How to make docker generate only differential layer for a pre-existing file change in base image?
body: <p>I am trying to generate a docker image using Dockerfiles the sequence is as follows</p>
  
  <p>1)Create an image using dokerfile that will copy abc.txt (size 200kb) in image</p>
  
  <p>2)Create another image using another docker file that will use previously generated image(in step (1)) as base image and copy file abc.txt(appended data and size=400kb)</p>
  
  <p><strong>When I check the layers of second image it shows the base image layers with second layer having size 200kb due to 200kb file(abc.txt) and top layer with 400 kb due to 400kb file(abc.txt)</strong></p>
  
  <p><strong>What i am expecting is on the top layer only the 200kb change of the file abc.txt should appear in second image but thats not the case when i do this.</strong></p>
  
  <p>Is there any other way I can achieve this?
  Any suggestions would be helpful.</p>
  
  <p>Thsese are my dockerfile contents
  :-</p>
  
  <h2>(1)for 1st image and when abc.txt size is 200kb:</h2>
  
  <p>From ubuntu</p>
  
  <p>COPY abc.txt /home/root/abc.txt</p>
  
  <hr>
  
  <p>After this I build the image using</p>
  
  <p>docker build -t ubuntu2 .</p>
  
  <h2>(2)For 2nd image and when I appended abc.txt resulting in 400kb size:</h2>
  
  <p>From ubuntu2</p>
  
  <p>COPY abc.txt /home/root/abc.txt</p>
  
  <hr>
  
  <p>I modified abc.txt and overwrite existing Dockerfile with above contents
  and built the image using</p>
  
  <p>docker build -t ubuntu3 .</p>