The Docker … The Easy Definition … Part (1)

Mohamed Abdeen
6 min readApr 18, 2018

--

Regardless of whether or not you have an immediate use-case in mind for Docker, For sure you have heard many new IT terminologies nowadays like DevOps, Micro Services, and Docker which is our today topic. I will not ask you to be Docker guru but at least you should know the definitions for all modern technologies, terminologies we are hearing every day. In today story, we will go through the basic understanding of The Docker.

Before going into what is the Docker? Let’s first understand what is a virtual machine and How is it different than Dockers?

But Why do we have VMs Or Dockers? What is the goal?

Containers and VMs are similar in their goals: to isolate an application and its dependencies into a self-contained unit that can run anywhere.

Moreover, containers and VMs remove the need for physical hardware, allowing for more efficient use of computing resources, both in terms of energy consumption and cost-effectiveness.

What is VM ?

It is an emulation of a real computer that executes programs like a real computer. VMs run on top of a physical machine using a “hypervisor”. A hypervisor, in turn, runs on either a host machine. A hypervisor is a piece of software, firmware, or hardware that VMs run on top of. The hypervisors themselves run on physical computers, referred to as the “host machine”. The host machine provides the VMs with resources, including RAM and CPU. These resources are divided between VMs and can be distributed as you see fit. The VM that is running on the host machine (again, using a hypervisor) is also often called a “guest machine.” This guest machine contains both the application and whatever it needs to run that application (e.g. system binaries and libraries). It also carries an entire virtualized hardware stack of its own, including virtualized network adapters, storage, and CPU — which means it also has its own full-fledged guest operating system.

First off, a hosted virtualization hypervisor runs on the operating system of the host machine. For example, a computer running OSX can have a VM (e.g. VirtualBox or VMware Workstation 8) installed on top of that OS. The VM doesn’t have direct access to hardware, so it has to go through the host operating system (in our case, the Mac’s OSX).

Well, since the VM has a virtual operating system of its own, the hypervisor plays an essential role in providing the VMs with a platform to manage and execute this guest operating system. It allows for host computers to share their resources amongst the virtual machines that are running as guests on top of them.

What is the container ?

containers are a way of packaging software.it is a lightweight, stand-alone, executable package of a piece of software that includes everything needed to run it: code, runtime, system tools, system libraries, settings. What makes them special is that when you run a container, you know exactly how it will run — it’s predictable, repeatable and immutable. There are no unexpected errors when you move it to a new machine, or between environments. All of your application’s code, libraries, and dependencies are packed together in the container as an immutable artifact

It is available for both Linux and Windows-based apps, the containerized software will always run the same, regardless of the environment. Containers isolate software from its surroundings, for example, differences between development and staging environments and help reduce conflicts between teams running different software on the same infrastructure.

You can think of running a container like running a virtual machine, without the overhead of an entire operating system. So, bundling your application in a container vs. a virtual machine will improve startup time significantly.

Containers vs. VMs

Containers and virtual machines have similar resource isolation and allocation benefits but function differently because containers virtualize the operating system instead of hardware. Containers are more portable and efficient.

The one big difference between containers and VMs is that containers *share* the host system’s kernel with other containers.

Can I use containers & VMs together ?

You will find the answer in the below diagram.

Reference : https://www.docker.com/

SO, The Docker … The Easy definition

Docker is an open-source project based on Linux containers. It uses Linux kernel features. It helps to create images , containers and manage both. Docker helps you create and deploy software within containers. It’s an open source collection of tools that help you “Build, Ship, and Run any App, Anywhere”. Yes, it really is as magic as it sounds.

Container or Image … Same OR Different

While you are reading more about the Docker. You will find yourself reading both terms containers, images so is it the same thing or there is a difference between both:

Using an object-oriented programming analogy, the difference between a Docker image and a Docker container is the same as that of the difference between a class and an object. An object is the runtime instance of a class. Similarly, a container is the runtime instance of an image.

An image is an ordered collection of root filesystem changes and the corresponding execution parameters for use within a container runtime. Images are read-only.

A container is an active (or inactive if exited) stateful instantiation of an image.

If you run the following the below Docker commands you get images & containers separately. [In Part 2 , we will install the Docker on your machine, Also we will run Docker Hello World example, Plus discover more about Docker commands… ]

More Important Terminologies to be considered:

Now we understand exactly what is the Docker and how it is different than VMs, Let’s cover the below terminologies:

Docker Daemon: The background service running on the host that manages the building, running and distributing Docker containers.

Docker Client : The command line tool that allows the user to interact with the Docker daemon.

Docker Store : Store is, among other things, a registry of Docker images. You can think of the registry as a directory of all available Docker images.

Docker File : is what you or developer write code to do something (ex- Install)

SO, The Process is

  • DockerFile — (Build) → Docker Image — (run) → Docker Container
  • Docker File is what you or developer write code to do something (ex- Install)
  • Docker Image is you get when you build Docker file .
  • Docker Container is you get when you run your Docker image

In the next Part (2) we will cover more about the below diagram, what is it? Docker Hello World, Docker Commands

Based on the above diagram, Let’s summarize

  • Pull Image form docker hub or build from Dockerfile => Gives a docker Image(not editable).
  • Run the Image(docker run image_name:tag_name) => Gives a running Image i.e. Container(editable)

The Docker engine takes the image and adds a read-write filesystem on top, then initialises various settings. These settings include network options (IP, port, etc.), name, ID, and any resource limits (CPU, memory). If the Docker engine has been asked to run the container it will also initialise a process inside it. A container can be stopped and restarted, in which case it will retain all settings and filesystem changes (but will lose anything in memory and all processes will be restarted). For this reason a stopped or exited container is not the same as an image.

Let me know in the comments if you have any feedback or feel free to reach out to me through my LinkedIn.

Or my about me Link. Follow me on Medium.

Don’t forget to hit the 💙 if you enjoyed this article.

Cheers and happy learning!

--

--