5

Pardon the dumb questions, but I've been learning about Docker and container technologies and I was learning about using Dockerfiles to specify build instructions for an image, and how each instruction creates a layer that will impact the overall size of the image generated.

I also learned that you can also attach to an image, as a base, and use it as any other server/vm, and commit the container as an image. This is the method I've been using in my few weeks of experimenting with Docker.

Is there any benefit to using one method vs the other? Is reusability enhanced either way? I was also able to push the image I created via container to the registry, is this best practice, or should I be keeping a repository of Dockerfiles?

  • Completely unrelatedly, the outfit in your profile picture looks dope. – Xiong Chiamiov Oct 13 '17 at 19:53
  • @XiongChiamiov thanks! Dapper and containerized – Glenak1911 Oct 13 '17 at 20:25
6

If one uses a Dockerfile then a colleague could also understand what happened (documentation as code). If one runs a container, enters it, runs commits then it would be hard to understand what packages were installed. Especially after a couple of months.

| improve this answer | |
  • Thanks for the reply, the use of versioned Dockerfiles makes sense in that context. One of my concerns is that I frequently work in air-gapped environments, so I figured it would be easier to build a complete image and then export it using docker pull image:tag docker save image:tag -o file.tar and then docker load -i file.tar once it's on their environment. I've run into enormous sizes of containers, and like you stated, it's difficult to keep track exactly what is on it. Dockerfiles would make it easier to build different versions of containers to share on a per instance basis. – Glenak1911 Sep 21 '17 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.