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 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?
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/ 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?
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
1 Like