title: Docker How to modify an existing image
body: <p>I created an image in docker. Installed Ubuntu, JDK in it and couple of other libraries. Then I exited the container and did a commit like this</p>
  
  <pre><code>docker commit a7b95082f6ea anil-ubuntu
  </code></pre>
  
  <p>I started the container again </p>
  
  <pre><code>docker run -p 5901:5901 -t -i anil-ubuntu
  </code></pre>
  
  <p>This time I installed gradle and couple of other libraries. And then exited the container and did a commit again.</p>
  
  <pre><code> docker commit a7b95082f6ea anil-ubuntu
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/gbQHJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gbQHJ.png" alt="enter image description here"></a></p>
  
  <p>Every time I do a commit a new image is created and older images with  repository and  tag remain. Very soon by following this workflow, I'll run out of space. Is this the right way of using docker ? How do I ensure that all these   images go away. </p>
  
  <p>I am using docker version 18.09.1 desktop on windows 10</p>