The long hash is its identification and we can use it for running containers. However, once we'd decide to do something more complicated, we'd have troubles to make it again.
So, we should always do things the way, we can reproduce it, which means using Dockerfiles instead.
This example results in the same output as the example before, except we can repeat it as many times we want and always get the same output. It also helps understanding the docker itself more as a packaging format, than anything else:
#> cat Dockerfile
FROM rhel7:7.2
RUN echo Hello Dojo > /root/greeting
#> docker build .
The following is an example of how we can create a very simple container:
What we must do first is to install and then to run the docker daemon:
Then we can download some image, that we'll use as a base of our image. Let's use something we trust, for example Red Hat Enterprise Linux 7.2:
Then, one way to create an image, is simply to run the container:
Then do some reasonable work, like creating some content -- in this case a file:
And finally, using
docker commit
we can create an image:The long hash is its identification and we can use it for running containers. However, once we'd decide to do something more complicated, we'd have troubles to make it again.
So, we should always do things the way, we can reproduce it, which means using Dockerfiles instead.
This example results in the same output as the example before, except we can repeat it as many times we want and always get the same output. It also helps understanding the docker itself more as a packaging format, than anything else: