Hello there! Probably today most of us are aware of the power that Docker bring to us, how it make easy and clean tasks that before could take time, resource and sometimes, cause some headaches too. I’ve been playing with Docker and I would like to write down some basic points that I think could clarify the whole thing, starting by Terminology.
I have no intention of cover everything, just touch those most common parts when using Docker. So, let’s start with a simple diagram. “I think I’m the visual kind, I love figures :)”
Here things happen when you start do edit a Dockerfile that is a recipe which describes the files, environment, and commands that make up an image, usually this file is contained in a directory, at first directory looks meaningless but you’ll forward (not in this post) that Docker uses the name of the directory to create containers when we use docker-compose.
After defining your Dockerfile is time to build the image that will be created on your local machine and will be used as a base definition for the containers that we’ll create using it. Confusing? You can think about images as classes and containers as instances.
Once you have your image you can run it to do whatever you want, just like you use to do on your own machine eg.
docker run --rm -it debian bash
Here, we’re executing bash in a container created based on debian image.
- –rm tells docker that this container should be deleted when it exits
- -it basically means that the container should be executed in interactive mode
Cool, let’s suppose that you made some changes in this container while you were using it and you want to keep these changes, the way to do this is committing your changes, then Docker will create a new layer on top of the image that you already have and next time when you run this image, the container created will have your changes.
Now if you want, you can share your changes, pushing them to the Repository that is basically a network/internet connected service that contains images and in the same fashion, you can update images “pull” with changes from somebody else.
To not make it too long I’ll break terminologies in more than one post, but hope that this short one gave you some basic idea for the daily basis.