Docker Community Forums

Share and learn in the Docker community.

Can Docker be a great version control system?

(Freesushi) #1

I heard that Docker can be used as a version control system even though it’s not the main feature.
So, how good is it as a version control system? Is it good enough to replace other version control systems out there?

(Jeff Anderson) #2

Docker itself is not a version control system.

The bits that you’ve probably heard about are referring to the layered image filesystem. Each container is started with a layered filesystem for its chroot. Each container gets a new write layer on top of that. Any changes to the filesystem can be committed as a new image layer.

This is not a version control system because it is tracking a whole virtual chroot, binaries and all. Additionally, there is a hard coded limit to the number of layers there can be.

A normal docker workflow is to re-generate layers regularly as upstream updates are published. Say my application’s base layer is ubuntu 14.04. the layers I add on top of that might capture installing packages, adding my own code, and setting metadata about my image. Say something like the heartbleed or ghost vulnerability happens, a new 14.04 image will become available. I’ll want to re-run all those commands where I install packages and add my own code. The result will be a completely new set of image IDs that aren’t related to the original set of images. I still have to maintain that other code and set of commands to rebuild an image. That is done with a Dockerfile, which is outside the image layer system itself.

Often times, you will want to continue to use a VCS system like normal, and use docker images as a deploy artifact only.

Hopefully this helps.


(Michael Wilde) #3

So Jeff, it would NOT be good design to deliver every file in a package as a different command in the dockerfile. (example, a splunk install has around 12000 files). I had a thought that each file would/could be delivered separately, so that during an upgrade, only new or changed files would be downloaded to all clients. Understanding there is also a fixed limit to the number of layers as well–my design would also fail.


(Jeff Anderson) #4

The approach that you are describing could work, and may even be ideal in some circumstances.

If you have an existing image already running on several nodes, and you want to do a small update to that image, you could use that existing image as a base. Any differences that you introduce could be collapsed into one layer that would then go out.

You definitely would not want to add one file at a time-- you’d get way too many layers to be practical.