# When to use docker commit versus the Dockerfile?

**URL:** <https://forums.docker.com/t/when-to-use-docker-commit-versus-the-dockerfile/2601>\
**Category:** General\
**Created:** [July 26, 2015, 10:31pm UTC](https://forums.docker.com/t/when-to-use-docker-commit-versus-the-dockerfile/2601 "2015-07-26T22:31:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dylanpowers](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/dylanpowers/32/1393_2.png) [@dylanpowers](https://forums.docker.com/u/dylanpowers)\
**Post date:** [July 26, 2015, 10:31pm UTC](https://forums.docker.com/t/when-to-use-docker-commit-versus-the-dockerfile/2601/1 "2015-07-26T22:31:40Z")

</div>

I’m trying to understand when it’s appropriate to do a docker commit versus leveraging the Dockerfile. I understand that the purpose of the Dockerfile is to make building docker images reproducible. Seeing how it is generally advisable to put everything that makes up a docker image into a Dockerfile, when is it appropriate to use docker commit? Is there a general rule of thumb?

I see that in the docs for [docker commit](https://docs.docker.com/reference/commandline/commit/) there is an example where docker commit is used to commit a change in an environment variable to specify a debug mode. Couldn’t that be specified in a Dockerfile? Is there a definitive case where a Dockerfile would be inappropriate?

---

<div class="post-metadata">

**Author:** ![dylanpowers](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/dylanpowers/32/1393_2.png) [@dylanpowers](https://forums.docker.com/u/dylanpowers)\
**Post date:** [July 26, 2015, 10:59pm UTC](https://forums.docker.com/t/when-to-use-docker-commit-versus-the-dockerfile/2601/2 "2015-07-26T22:59:29Z")

</div>

Some more info:  
I’ve found and read [http://nathanleclaire.com/blog/2014/09/29/the-dockerfile-is-not-the-source-of-truth-for-your-image/](http://nathanleclaire.com/blog/2014/09/29/the-dockerfile-is-not-the-source-of-truth-for-your-image/) The conclusion I’m getting from it is that I shouldn’t be deeply concerned about having all operations in a Dockerfile. While it’s a good idea to put a lot of the more tedious steps there, it isn’t strictly necessary, and interactively creating an image using docker commit is okay too.  
Is that a correct conclusion for me to make that holds up in docker today?

---

<div class="post-metadata">

**Author:** ![svendowideit](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/svendowideit/32/119_2.png) [@svendowideit](https://forums.docker.com/u/svendowideit)\
**Post date:** [July 27, 2015, 12:07am UTC](https://forums.docker.com/t/when-to-use-docker-commit-versus-the-dockerfile/2601/3 "2015-07-27T00:07:22Z")

</div>

I find it more maintainable to use a set of Dockerfiles for everything.

I use a set so that I can re-use common layers in other images, and pretty much haven’t found a need to use `docker commit` in ages.

And yes, I specify ENV values in the Dockerfiles too
