IoT Lab KIIT
Published in

IoT Lab KIIT

A complete overview of Docker

DOCKER: Basic to expertise level explanation

SOURCE: https://www.docker.com/company/newsroom/media-resources

We are sure everyone might have heard the word DOCKER if anyone is acquainted with Cloud Computing. This article is a small try to venture into the world of Docker. I, Arnab along with my friend Ayshi have written this article on Docker. So let's come to the point

What Docker really is?

Docker is free software developed by Docker Inc, was released in the market in the year 2013, and has become a key tool in the world of IT Development.

Mainly inside DevOps, there is a tool that we use a lot for solving multiple use cases, is known as Docker. Technically the docker started just to ship our application or build our things. Through research, it comes to know that almost in all the environments one can use docker. It allows users to create independent and isolated environments to launch and deploy their applications. Due to this kind of nature of Docker, it is very safe and secured to use.

Basic Commands of RHEL 8.0 GUI

PROVISIONING OF OPERATING SYSTEM (OS) :

If we want to use an application or software then at first we have to run the program. Then the program becomes a process and it will load on the RAM. Before running any process we require Operating System(OS). For provisioning of OS, there are four different ways are available in the market. Those are —

1)Bare Metal: By using this technique one can directly install OS on the top of the hardware and it takes 30–60 mins time to launch OS. Limitations of this technique are: there is a huge wastage of resources (RAM, CPU, network card). Even though OS is booting up, one use or don’t use, it won’t allow other OS to use the same hardware.

2)Cloud Computing: This technique takes time to launch OS in 30–60 mins.

3)Virtualization: In one single hardware, if one can launch multiple OS, called virtualization. This technique takes 30–60 mins time to launch OS. The main program which is doing the virtualization process is called Hypervisor. Limitations of virtualization are *It creates a security risk,*It creates an availability issue,*It is time-consuming,*It creates a scalability issue.

Drawbacks of both bare metal and virtualization are resolved by docker.

4)Containerization: By using this technique one can launch almost any OS with an internal application like web server, database server, take time to launch OS in 1 sec and just in 1 sec the entire OS gets booted and installed also]. The product that will run behind the containerization technique is Docker.

For launching OS on any platform we require an OS image. Similarly, if we want to launch any OS in the docker we require Docker Image. In the docker world, this OS is technically known as Container. A Docker container is an open-source software development platform that includes everything needed to run an application: code, runtime, system tools, system libraries, and settings. Whatever data saved inside the container is permanent.

The system where docker is installed is called Red Hat. Top of the Red Hat docker service or engine is installed. Top of the docker multiple OS is launched. Here Red Hat (RHEL 8) is the docker host.

How Docker works
Source: https://www.docker.com/resources/what-container

Basic Commands Related to Docker :

Docker Hub :

Docker community has its own internet URL. Almost all the main OS images like Red Hat, Centos, Ubuntu are put on one website. The location where they put all the docker images or OS images is typically known as Repository or Public Registry or Docker Hub. Basically, it is the official online repository where we can find all the Docker Images that are available to use. We can download any image from the docker public repository that is hub.docker.com. Also in the Docker Hub, we can store and distribute our custom images. We can also make those images either public or private, based on our requirements. Free users are only allowed to keep one Docker Image private. If you wish to keep more than one Docker Image private, you need to subscribe to a paid subscription plan.

DIFFERENCE BETWEEN VIRTUALIZATION AND CONTAINARIZATION :

VIRTUALIZATION : (i)Here Oracle virtual box is used (ii)OS is known as VM (Virtual Machine)(iii)For launching new OS here we have graphical way and commands also (iv)To start OS have to click just start (v)To shut down OS: right-click -> close -> power off (vi)Here from the list we can see the all the OS.

CONTAINARIZATION : (i)Here Docker is used (ii)OS is known as the container (iii)For launching new OS here we have a command called docker run (iv)To start OS here we have a command called docker start (v)Here we have 2 ways to shut down OS *Inside container: exit *RedHat OS: docker run (vi)Here we have a command called docker ps -a to see all the OS that is being currently running or stopped.

Yum is a command or tool in RedHat. It is a tool through which we can install the software. In container yum is already been configured :

If you want to get ifconfig command then have to install the software: yum install net-tools.

COMMANDS :

OLD COMMAND / ABSOLUTE COMMAND :

Container : yum, stop, start, ps, rm

NEW COMMAND / MANAGEMENT COMMAND: Per uses basis categorized all the commands is known as Management Command.

CREATE YOUR OWN IMAGE :

There are two ways to launch the own image : (i) Commit (ii) Docker file

(i) Commit Method: First, pull an image(let centos:7) from the docker hub. Then launch that image into your own created OS. Lots of containerization is not possible in the commit method.

(ii) Docker file: In this case, use a file of instructions — the Docker file — to specify the base image and the changes you want to make to it.

LAUNCH A OS TO CONFIGURE OR SET UP APACHE WEB SERVER :

Apache web server is software where we are going to set up this software inside Centos.

docker attach c1

docker exec c1 date

Basically, the above-mentioned two commands are the same. Both commands help to go inside the container. The attach command automation process doesn’t exist because it is an interactive command and by running attach command we will go inside the different OS that’s why our script hangs up or maybe failed. This is the only reason that it is recommended to use the exec command because here it will help us to go inside the container, run the date command, give the output and come back.

After running attach command when we do the exit command it shut down the container. But using the command: docker exec -it c1 bash => it helps to go inside the container and run the bash command, give bash prompt. At this point if we use the exit command it is not shutting down the container, it is exiting out from the bash.

To check the services stopped or not open a new terminal and run the command: curl<IP Address>

When one starts services/program, services launch on the top of memory i.e RAM. Whatever data we have in RAM it will be there till OS is running. As soon as we shut down the OS all the data from memory lost means services/programs also lost. When we reboot the OS again whatever data store in storage will be there but the program is not showing.

After reboot, the commands are : *httpd *net stat —tnlp

[Sometimes stop command does not work that’s why the alternative command is: killall httpd]

To share the OS :

Exporting docker image using “docker save” and sharing it.

Importing Docker image using “docker load”.

Uploading our own image in docker hub.

NETWORKING :

Networking is a communicating medium between the containers or between the container and the outside world via a host machine as a router. Docker supports different types of networks, each fit for certain use cases.

Application: Network is a great way to manage a container or OS, a gateway to have a local connection between the containers, gateways to provide isolation, and the most important thing to provide security.

From one single hardware setup create multiple networks: MULTI-TENANT. Any OS which is not connected to the internet is the most secure one.

HOW NETWORKING WORKS

Switch / Bridge Network: Among three networks Bridge Network is the most common type of network. First of all, there is no container inside the OS. But whenever any OS is launched, by default they launch in a network called a bridge. As soon as a container is launched, automatically one wire is connected from the network card to the switch port or bridge port. Then OS will send a request to DHCP and DHCP will give IP address and gateway address also.

HOW TO CREATE OWN PERSONAL NETWORK :

HOW BRIDGE NETWORK IS CONNECTED

If you create a network with any name with a driver called bridge then only they create a switch and router and then only the router creates connectivity with the outside world. Then DHCP server is created and connect DHCP to the bridge. Now one can decide which network range he/she wants to give the DHCP. Whatever network range one gives to the DHCP, the container will pick the IP address from those.

WHAT IS KERNEL :

When you boot your OS [the 1st thing that boots in the OS], the name of the program which is the main part of your OS, is known as Kernel. All the drivers are part of a Kernel. When OS boots, kernel scan complete hardware (RAM, Network card, graphics card, etc.). Whatever devices kernel find they load the driver. Then all devices start working. OS or user can communicate with this.

DOCKER ARCHITECTURE :

The Docker architecture uses a client-server model and comprises the Docker Client, Docker Host, Network and Storage components, and the Docker Registry/Hub.

Docker Client: The Docker client enables users to interact with Docker. The main purpose of the Docker Client is to provide a means to direct the pull of images from a registry and to have it run on a Docker host. Common commands issued by a client are:

Docker Host: The Docker host provides a complete environment to execute and run applications.

Docker Objects: Various objects are used in the assembling of your application. The main requisite Docker objects are images, containers, networking, storage, docker registries.

Storage: If you have any data, if you like to store data permanently (called persistent) then you have to store it on your hard disk or any devices. These devices are known as storage devices/storage.

Two types of storage are present: i) Ephemeral Storage[anything i.e temporary] ii) Persistent

Create persistent storage :

Whatever you set in the set it is temporary. After close the terminal, it won’t work. That’s why we have to make it permanent. For that use command : vim root / .bashrc . After running this command at the end write: alias del = ‘docker rm -f $(docker ps -a -q)’ and then write :wq

Now alias is permanent. Close the terminal and again open and run: alias

Docker Registry/Hub: Docker registries are services that provide locations from where you can store and download images. Common commands when working with registries include:

Block Diagram of Docker Architecture. Source: https://docs.docker.com/get-started/overview/

The IP that is running inside the container is the private IP. Whatever you have outside the laptop it feels that you have a public IP. Anybody outside the world who tries to connect the IP of the container c1, won’t able to reach laptop 1.

When docker is launched inside RedHat they created a router known as a bridge. In the router two network card is added. 1st network card is connected to the outside world and 2nd network card is connected to the docker world. [As shown in the below figure]

The need for a Router: It is used to connect two networks. It is one internal program that docker has. It has two network cards that is docker 0 which is connected to the internal world and one network card enp0s3 is connected to the outside world. enp0s3 is the main network card of RedHat that has outside connectivity of modem, hotspot, broadband, or whatever setup one has.

HOW ROUTER IS CONNECTED WITH THE OUTSIDE WORLD

DRAWBACKS OF USING DOCKER:

Applications with different operating system requirements cannot be hosted together on the same Docker host. For example, let’s say we have 4 different applications, out of which 3 applications require a Linux-based operating system and the other application requires a Windows-based operating system. In such a scenario, the 3 applications that require a Linux-based operating system can be hosted on a single Docker Host, whereas the application that requires a Windows-based operating system needs to be hosted on a different Docker Host.

CONCLUSION :

It was a roller-coaster ride on our session to Docker. We learned about Docker technology and how it is an important tool in the modern IT world. Docker is a technology that simplifies isolation and provides environment independence. However, in this current scenario, we can basically use it for the development and testing environments.

So that's for now. We hope you all got a clear idea about what docker is and will try to implement it in the real world. This will make your journey as a cloud enthusiast more exciting!

And We would like to thank Avik Kundu (Cloud Lead), without whose help the project has been really unsuccessful.

THANK YOU FOR YOUR PATIENCE FOR READING THE ARTICLE.

NEXT TIME WE WILL COME UP WITH MORE EXCITING ARTICLES.

You can connect us on Instagram, Instagram, and LinkedIn, LinkedIn if you need more help. We would be more than happy.

Good Luck 😎 and happy coding 👨‍💻

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store