Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 392
Jeff Fairley Avatar asked Jan 23 '15 18:01

Jeff Fairley


1 Answers

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.

like image 79
Javier Cortejoso Avatar answered Oct 16 '22 16:10

Javier Cortejoso