A Beginner-Friendly Introduction to  Docker

A Beginner-Friendly Introduction to Docker

Introduction

Hello folks , so i recently started learning about Docker and here are some of my Insights on Docker . Docker is an open-source platform widely used by software companies that facilitates the shipment of applications quickly. It is an alternative to virtual machines which allows you to run different operating systems on one computer. In this article, I will be introducing Docker, Benefits of Docker and Docker Architecture.

What is Docker

Docker is a container platform which is designed to allows you to build, test and deploy applications quickly in an isolated System. Docker containers are lightweight alternatives to Virtual Machines and it uses the host OS. In Docker we don't need to allocated any RAM.

For all intent and purposes, containers look like a VM. For example, they have private space for processing, can execute commands as root, have a private network interface and IP address, allow custom routes and iptable rules, can mount file systems, and etc.

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

1_V5N9gJdnToIrgAgVJTtl_w.png

Each container gets its own isolated user space to allow multiple containers to run on a single host machine.

Benefits of Using Docker

1.Ease of use: Docker has made it much easier for anyone — developers, systems admins, architects and others — to take advantage of containers in order to quickly build and test portable applications. It allows anyone to package an application on their laptop, which in turn can run unmodified on any public cloud, private cloud, or even bare metal. The mantra is: “build once, run anywhere.”

2.Speed: Docker containers are very lightweight and fast. Since containers are just sandboxed environments running on the kernel, they take up fewer resources. You can create and run a Docker container in seconds, compared to VMs which might take longer because they have to boot up a full virtual operating system every time.

3.Docker Hub: Docker users also benefit from the increasingly rich ecosystem of Docker Hub, which you can think of as an “app store for Docker images.” Docker Hub has tens of thousands of public images created by the community that are readily available for use. It’s incredibly easy to search for images that meet your needs, ready to pull down and use with little-to-no modification.

4.Modularity and Scalability: Docker makes it easy to break out your application’s functionality into individual containers. For example, you might have your Postgres database running in one container and your Redis server in another while your Node.js app is in another. With Docker, it’s become easier to link these containers together to create your application, making it easy to scale or update components independently in the future.

Fundamental Docker Concepts

1_K7p9dzD9zHuKEMgAcbSLPQ.png

Docker registry

Docker registry is a storage component for Docker images. We can store the images in either public or private repositories. DockerHub is famous public cloud repository.

Docker Engine

Docker engine is the layer on which Docker runs. It’s a lightweight runtime and tooling that manages containers, images, builds, and more. It runs natively on Linux systems and is made up of:

  1. A Docker Daemon that runs in the host computer.
  2. A Docker Client that then communicates with the Docker Daemon to execute commands.
  3. A REST API for interacting with the Docker Daemon remotely.

Docker Daemon

It listens to the API requests being made through the Docker client and manages Docker objects such as images, containers, networks, and volumes.

Docker Client

The Docker Client is what you, as the end-user of Docker, communicate with. Think of it as the UI for Docker.

Dockerfile

A Dockerfile is where you write the instructions to build a Docker image. These instructions can be:

RUN apt-get y install some-package: to install a software package.

EXPOSE 8000: to expose a port.

ENV ANT_HOME /usr/local/apache-ant to pass an environment variable

and so forth. Once you’ve got your Dockerfile set up, you can use the docker build command to build an image from it

Docker Image

Images are read-only templates that you build from a set of instructions written in your Dockerfile. Images define both what you want your packaged application and its dependencies to look like and what processes to run when it’s launched.The Docker image is built using a Dockerfile.

Docker Container

A Docker container wraps an application’s software into an invisible box with everything the application needs to run. That includes the operating system, application code, runtime, system tools, system libraries, and etc. Docker containers are built off Docker images. Since images are read-only, Docker adds a read-write file system over the read-only file system of the image to create a container.

1_hZgRPWerZVbaGT8jJiJZVQ.png

Moreover, then creating the container, Docker creates a network interface so that the container can talk to the local host, attaches an available IP address to the container, and executes the process that you specified to run your application when defining the image.

Docker Compose

Docker Compose can connect different containers as a single service. Docker Compose is used for running multiple containers as a single service. Each of the containers run in isolation but can interact with each other when required. Docker Compose files are very easy to write in a scripting language called YAML, which is an XML-based language that stands for Yet Another Markup Language. Another great thing about Docker Compose is that users can activate all the services (containers) using a single command.

Docker Volume

Docker Volume facilitates the independent persistence of data, allowing data to remain even after the container is deleted or re-created

Conclusion

That's all for now. Please like ,share and comment if you found this information informative. If you have any questions, please leave them in the comments section and I will do my best to answer them. Thanks for reading . Any feedbacks are welcome!! :) Connect me on Twitter | Github