Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Welcome you all for the PART - 2 of this series. !! Time to roll up the sleeves and deep dive in to Docker containers. Thanks to my colleague ujwaliyer  for helping me out in co-authoring this series.

Before you continue reading about docker containers, in case if you had missed on Containers – Introduction, Please refer to this link for PART - 1

Now that we talked about Containers introduction in PART - 1, we will talk in detail about Docker containers in this post.

Question: Docker is a company or a tool?

Docker is a tool provided by Docker Inc which helps in containerizing the application.

Question: Why we are focusing on Docker? Aren’t there any other tool out there to containerize the application?

Dockers are used to containerize the application due to various reasons and they are the leader in the market. Dockers are lightweight, open, secure etc., and hardly takes few minutes to install in any environment.

There are also other alternatives to Dockers like rkt, LXC etc.,to containerize an application. But let us focus on DOCKER CONTAINERS.

Definition of Docker Containers

Docker containers wrap a piece of software in a complete filesystem that contains everything needed to run: code, runtime, system tools, system libraries –  anything that can be installed  on a server. This guarantees that the software will always run the same, regardless of its environment.
     Credits: PHP Image, Ubuntu Image, Library Image                                                                          Credits : CC BY-SA

 

Unlike VM’s, which will occupy space in GB’s, there is no need for an environment in GB’s for docker containers. A container could be as small as 50MB. The transfer of docker container becomes very easy for other people to access and test.

Let us see how Docker makes this possible.

Architecture diagram


Let’s Break it down!!!!!!!!!!!!!!

Let us take laptop as an example. Laptop is the hardware and an operating system will be installed on the hardware. It might have windows/Linux installed. We have the hardware set, operating system set. Next is the container engine. Container engine is the docker software that we would install on top of the operating system. Once we install the container engine, we can run any containers. For example: if our code needs ubuntu container, we can deploy that easily. If we need a CentOS container, then we can deploy it easily. A question will pop up now?
How is the container so low in size? When an application is dependent on Ubuntu or Cent OS, how come this CentOS container is very small? As small as 50MB? What is the fundamental behind this?

The container does not contain all the operating system files like how a VM or normal OS does. A container does not have a Kernel. It shares the kernel of the operating system. It doesn’t have the kernel on its own. If the application is dependent on Ubuntu, we then download the Container for Ubuntu, then it would feel like we like we are working on Ubuntu operating system. Underneath, our container is just sharing the resources with underlying OS. But our container has minimum binaries and libraries that required to run the ubuntu command.

For Example: Yum install package name. if you execute this command YUM INSTALL <PACKAGE NAME> within a container this will work. But can you try SUDO command for switching the user and check whether it works? NO. This will not work. Why? Because, a container is nothing but a set of binaries and libraries which are important for the Ubuntu Commands to work, With the underlying virtualization of the kernel and BIOS of the OS. It seems to be they are on their own running an operating system. This is the reason why they are so lightweight. They don’t require all the files of an operating system and they require only bare minimum files and libraries required for the particular environment to work.

Coming back to our architecture diagram,

we have the hardware, OS and container engine installed and these containers will have minimum libraries. And on these containers, we will put our code. On one container, Let us put our PHP Code. There could be multiple containers. Multiple applications in multiple containers. For example: PHP in Ubuntu container, word press document in Cent OS container etc. you can have “n” applications in “n” containers.

Hope till this step it should be clear. At least answering questions like what is Docker containers, why Containers are light weight?.  If any confusions (normally happens with beginners like it had happened  for me) please hold your questions, The confusions and questions will get sorted out later wherein step- by step setup will be explained in the system.

Now, Let us have a walkthrough of VM vs containers. This is quite important as people should understand the basic difference between a VM and Docker containers.

Difference between Virtual Machines and Containers

Architecture for a Virtual Machine


 

If you can look at the architecture diagram, We have the Hypervisor instead of container engine. On top of the Hypervisor we have the VM’s with Guest OS for each VM. And different applications deployed in each and every VM. But in case of VM we have a whole Operating system but in container engine we have only the required binaries and libraries. Because of the whole operating system, the size will be huge for VM. It totally depends on the specs of the hardware how many VM’s that it could hold.

Question Pop-Up

We have been discussing about Docker containers, architecture diagrams, VM’s vs Container. Then what is all the fuss about DOCKER IMAGE!!!. What is a docker image? Are Docker containers and Docker Images are the same?

Docker Image: A Docker image is a read-only template that contains a set of instructions for creating a container that can run on the Docker platform.

Your Mindvoice right now !!
Enough of the Book explanation 😊 what is a Docker Image in layman terms?

You package your entire environment (like how we saw it in Part – I, software dependencies like binaries, libraries, etc.,) in to Docker Images. Bundling the entire environment to an Image

What is Docker container then?. You need a place to run these images (Its like imagine you need a plate to hold the food items). Food is the main content, but you need something to hold it off which is the plate. In similar fashion, Docker containers are the placeholders for the images to run.

When you run the Docker images, the container will be created and started. But when you decide to delete the container, Only the container will be deleted but the Images will still be retained. You have to explicitly delete the images as well in case you do not want the image also.

Let us see additional details  once we get into the system step by step in the next Part of the blog from which you will have a better understanding.

See you in PART -3 where we will start with Docker Installation. Brace yourselves and Happy learning !!!!!!!