Jeff Fairley
Jeff Fairley

Reputation: 8324

Dockerfile vs Docker image

I'm working on creating some docker images to be used for testing on dev machines. I plan to build one for our main app as well as one for each of our external dependencies (postgres, elasticsearch, etc). For the main app, I'm struggling with the decision of writing a Dockerfile or compiling an image to be hosted.

On one hand, a Dockerfile is easy to share and modify over time. On the other hand, I expect that advanced configuration (customizing application property files) will be much easier to do in vim before simply committing an new image.

I understand that I can get to the same result either way, but I'm looking for PROS, CONS, and gotchas with either direction.

As a side note, I plan on wrapping this all together using Fig. My initial impression of this tool has been very positive.

Thanks!

Upvotes: 10

Views: 4703

Answers (2)

Ninux
Ninux

Reputation: 121

I totally agree with Javier but you need to understand that one image created with a dockerfile can be different with an image build with the same version of the dockerfile 1 day after.

maybe in your build process you retrieve automatically last updates of an app or the os etc …

And at this time if you need to reproduce a crash or whatever you can’t rely on the dockerfile.

Upvotes: 12

Javier Cortejoso
Javier Cortejoso

Reputation: 9176

Using a Dockerfile:

  • You have an 'audit log' that describes how the image is built. For me this is fundamental if it is going to be used in a production pipeline where more people are working and maintainability should be a priority.
  • You can automate the building process of your image, being an easy way of updating the container with system updates, or if it has to take part in a continuous delivery pipeline.
  • It is a cleaner way of create the layers of your container (each Dockerfile command is a different layer)

Changing a container and committing the changes is great for testing purposes and for fast development for a conceptual test. But if you plan to use the result image for some time, I would definitely use Dockerfiles.

Apart from this, if you have to modify a file and doing it using bash tools (awk, sed...) results very tedious, you can add any file you wish from outside during the building process.

Upvotes: 13

Related Questions