Introducing docker – Part I: Overview

Tram Ho

I. What is Docker?

Docker is a platform that provides a way to make building, deploying, and running applications easier using containers (on a virtualization platform).

Easier example: Imagine you code an App: Including Database MySQL, JDK, NODEJS, … After coding and testing the types, you start deploying it on the server. And the problem here, you code on the window but your server runs unbuntu and starts to have some things on the window you can easily install, but ubuntu then you have to tinker, and then get error when installing, or different version, …

So is there a way to just pick up the application and run it instead of installing a mess? The answer is docker.

Docker will do the bundling of necessary parts into something called a container.

II. What is Container in Docker?

Container concept: Containers allow a programmer to package an application with all the necessary parts, such as libraries and other dependencies, and package it all out as a package.

That way, thanks to the container, the application will run on every other Linux machine regardless of any custom settings the machine might have different from the machine used to write the code.

Easier example: You have a freezer, you fish Ayu (Japanese fish and only summer – according to the anime) and stuff it in that freezer. So even if summer is over, if you want to eat, just take out the freezer and start enjoying.

In a way, Docker is quite similar to a virtual machine. But why did Docker grow in popularity so quickly? These are the reasons:

Ease of application: Docker is easy for everyone to use from programmers, sys admin … it takes advantage of the container to quickly build and test. The app can be packaged on their laptop and run on public cloud, private cloud… The incantation is “Build once, run anywhere”.

In terms of speed: Docker containers are very light and fast, you can create and run the docker container in seconds.

Runtime and extensibility: You can break down the functionality of an application into separate containers. The Database instance runs in one container and the Redis cache can run on another container while the Node.js application runs on another. With Docker, it’s easy to link containers together to form an application, making it easy to scale, update independent components together.

III. Main concepts

  • Docker Engine: is the main component of Docker, as a tool for packaging applications
  • Docker Hub: is a “github for docker images”. On DockerHub there are thousands of community-generated public images that allow you to easily find the images you need. And just pull back and use with some config you want.
  • Images: is a template for creating a container. Usually the image will be based on an existing image with additional customizations. For example, you build an image based on a sample Centos image available to run Nginx and customize and configure your web application to run. You can build your own image or use images shared from the Docker Hub community. An image will be built based on the Dockerfile instructions.
  • Container: is an instance of an image. You can create, start, stop, move or delete containers based on Docker API or Docker CLI.
  • Docker Client: is a tool that helps users communicate with Docker host.
  • Docker Daemon: listens to requests from Docker Client to manage objects such as Container, Image, Network, and Volumes through the REST API. Docker Daemon s also communicate with each other to manage Docker Services.
  • Dockerfile: is a file that contains instructions for building an image.
  • Volumes: is the piece of data that is created when the container is created.

How does Docker work?

As shown in the figure, a Docker system is implemented with 3 main steps:

  • Build .

First we will create a dockerfile, in this dockerfile is our code.

This Dockerfile will be Build on a computer that has Docker Engine installed.

After building we will obtain the Container, in this Container contains our library and application.

  • Push .

After having the Container, we push this Container to the cloud and store it there.

This push can be done over an Internet environment.

  • Pull, Run

Suppose a computer wants to use the Container we pushed to the cloud (the machine has installed Docker Engine), the machine must pull this container back to the machine. Then execute this Run Container.

It is a 3-step process that describes the operation of a system using Docker. Very simple and clear.

IV. summary

Here is an overview so you can get an overview of what docker is. In the article next week I will go deeper about docker and the example article.

References

https://docs.docker.com/get-started/overview/#:~:text=Docker uses a client-server, to a remote Docker daemon . https://luanbn.wordpress.com/2015/08/27/docker-part-2-cau-truc-va-quy-trinh-hoat-dong-cua-docker/

Share the news now

Source : Viblo