<p>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.</p>

CC BY-SA 3.0
2017-09-21T18:43:55.593Z
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
CC BY-SA 4.0
2017-09-21T16:31:01.657Z
2018-11-27T16:06:43.740Z
2018-11-27T16:06:43.740Z
030
<p>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.</p>

<p>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.</p>

<p>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?</p>

CC BY-SA 3.0
2017-10-13T19:53:34.707Z
Completely unrelatedly, the outfit in your profile picture looks dope.
Xiong Chiamiov
CC BY-SA 3.0
2017-10-13T20:25:03.650Z
@XiongChiamiov thanks! Dapper and containerized
Glenak1911
<docker><dockerfile><containers>
Docker Images via Container vs Dockerfile
Glenak1911
# Docker Images via Container vs Dockerfile

(Asked by: username_0 on 2017-09-21)

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?

**Tags:** docker, dockerfile, containers

> **Comments:**
> **username_1**: Completely unrelatedly, the outfit in your profile picture looks dope.  
> **username_0**: @XiongChiamiov thanks! Dapper and containerized  

---

## 1 answers

### Answer by username_2 on 2017-09-21. Score: 7 | Accepted answer

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.

> **Comments:**
> **username_0**: 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.  

---

