in DevOps

Docker – down the rabbit hole

What happens when you type docker run centos /bin/echo hello world the first time?

Docker could not find the required image locally, so Docker downloaded the required files. Wait a moment… What required files and why plural?

The basic element in Docker are images. These are basically prebuilt operating systems, often with preinstalled applications. A good overview can be found at Docker’s github page.

But why would Docker download five images?
Lets have a look at the installed images:

Looking at the IMAGE ID column we identify three of our downloads. Tags centos7 and latest share the same id.
To find the missing ones we have to issue the images command with the tree parameter.

Found them! Found what?

Docker never forgets

A Docker image is built on layers. With every command a new layer is created. You can even go back to a previous layer. And that is how the tree structure is created and one of the largest benefits of docker is made.
Let’s play with these layers. First run a new command to modify the existing centos container:

With docker list command we can get the Container ID (-a is used for non-running containers):

We use the generated ID to commit a new layer:

It created a new TAG named touch_test for the centos Repository.

Looking inside we see a test file in the root folder:

To be continued