Docker updates image when dockerfile changes

I play with docker creating a Dockerfile with some nodejs instructions. Right now, every time I make changes to the docker file, I recreate the image by running sudo docker build -t nodejstest . in my project folder, but this creates a new image every time and swallows my ssd pretty soon.

Is there a way to update an existing image when changing the dockerfile or am I forced to create a new one every time I make changes to the file?

Sorry if this is a dumb question

+46
docker
Sep 14 '13 at 16:54
source share
3 answers

Docker build support caching if there is no ADD instruction. If you are actively developing and modifying file files, then only after ADD will it be rebuilt.

Starting with 0.6.2 (scheduled today), you can do docker build --rm . and it will remove the temporary containers. It will save images though.

To remove orphaned images, you can check them with docker images and run docker rmi <id> on one of them. At the moment, there is an automatic configuration, and all untagged images (orphans, previous assemblies) will be deleted.

+35
Sep 17 '13 at 21:19
source share

According to this best practice guide , if you save the first lines of your docker file, it will also cache them and reuse the same images for future buildings

+10
Jan 23 '14 at 7:36
source share

During development, it makes no sense to rebuild the whole container for each commit. You can later automate the creation of a Docker container with the latest code as part of the QA / deployment process.

Basically, you can choose the minimal container that retrieves the code (using git when starting the container or using -v /home/myuser/mynode:/home/myuser/mynode with ENTRYPOINT to start the node).

See my answer to this question:

Docker rails and git app

+1
Sep 15 '13 at 19:08
source share



All Articles