Monday, December 6, 2021

Docker Tutorial: Introduction to Docker

Docker is a containerization technology for developing, shipping, and running applications.


What is Docker

Docker is an open platform which helps in developing, deploying and running applications in a same standardized environment. One of the main tasks while developing any application is to have development, test and production environment and ensuring that all the dependencies that are required to run the application are properly installed so that the code running in one environment doesn't stop working in another environment when deployed.

Different Environments

With Docker you can package and run an application in a loosely isolated environment called a container. A standard Docker container contains everything needed to run the application, so you do not need to rely on what is currently installed on the host. Here main point is that it "contains everything" which means-

Application Code + binaries + libraries

This standardization allows containers to run in any environment so you can easily share containers and be sure that everyone you share with gets the same container that works in the same way.

Docker platform helps in managing the application lifecycle-

  1. You can develop your application using containers.
  2. Same container can be distributed to other developers (as Docker image) working on the same projects so that all have the same version of dependencies.
  3. Deploy your application into your test environment, as a container.
  4. When application is ready, deploy your application into your production environment, as a container.

Containerization Vs Virtualization

If there is a need to run several applications on one machine, before Docker standard way to do that was creating Virtual Machines (VMs). With VMs you get full process isolation as each VM has its own OS so with in a system you have multiple operating systems and a hypervisor sits between the host system and VMs to share and manage the hardware and to manage guest operating systems.

Virtual machines

Containerization is different from virtualization because each container shares the kernel within the host OS. Each container won't have an OS installed they share the underlying host OS kernel with the other containers. With Docker the entity that sits between the host OS and the containers and also responsible for creating and running containers is known as Docker engine.

Containerization

Basic Docker terminology

As a beginner first three phrases you will encounter are Dockerfile, image and container.

  • Dockerfile- Dockerfile is a file having instructions to create the image and run it. Each instruction in a Dockerfile creates a layer in the image. See an example of creating a Dockerfile in this post- Run Java Application in Docker Container
  • Image- Using Dockerfile you can build your own image or you can just pull images created by others and published in a registry. An image is a read-only template with instructions for creating a Docker container.
  • Container- A container is a runnable instance of an image. A Container run as standalone entity well isolated from other containers and its host machine.

Docker architecture

Docker uses a client-server architecture. Using client you can send commands like docker build, docker run and Docker daemon does the actual task of building, running, and distributing your Docker containers. The Docker client and daemon communicate using a REST API.

docker build command is used to build an image following image shows the communication between client and daemon to execute this command

Docker architecture

Advantages of Docker

  1. As we have seen in the section Containerization Vs Virtualization, containers share the host OS that makes them very lightweight, memory efficient and fast.
  2. Docker containers are portable and can run in any environment. Docker containers can run on a developer’s local system, on physical or virtual machines in a data centre, on cloud providers or in a mixture of environments without making any change in the code.
  3. This portability also makes scaling up and tearing down applications scalable. It is as easy as running more containers or stopping containers.

Reference: https://docs.docker.com/get-started/overview/

That's all for this topic Docker Tutorial: Introduction to Docker. If you have any doubt or any suggestions to make please drop a comment. Thanks!


Related Topics

  1. Installing Docker on Windows
  2. Run Python Application in Docker Container
  3. Java Application With User Input in Docker Container

You may also like-

  1. Java Stream API Tutorial
  2. ConcurrentSkipListMap in Java With Examples
  3. Constructor Overloading in Java
  4. Java Multithreading Interview Questions And Answers
  5. Python Generator, Generator Expression, Yield Statement
  6. Spring MVC XML Configuration Example With Annotations
  7. How to Check Hadoop MapReduce Logs

No comments:

Post a Comment