Docker Community Forums

Share and learn in the Docker community.

Is there any difference to create images between these two ways?

    • create images with docker files
    • interactive with a container based on which i create a new image

(Metin Y.) #2

Building an image from the Dockerfile is the only way to declare every aspect of your image.
On top it is reproducable (if you fix package versions) and self documenting.

Many instructions for the Dockerfile are not available for a container based “build”.


Nice answer. What if it takes many steps to build the final image and every step requires timely feedback of results。If i choose to write down all instructions,i don’t think it’s a good idea to run “docker build” repeatedly. The combination of these two ways may be the best?

(Metin Y.) #4

Are your aware that docker build has a build cache? It only builds the changed and all following instructions of the Dockfile. The cache plays out fine if you organize your Dockerfile in way that changes are close to the buttom of your file. Rearranging your instructions in your Dockerfile is considered as change.

Don’t bother trying the interactive approach: It is wrong on so many levels.


Got it. Still a lot to learn. Thank you very much for your reply.