Day-01 of #40DaysOfKubernetes.

Docker Fundamentals.

·

4 min read

1. Why we need containers.

  1. Traditional Challenges: Things works fine on development environment, test environment, but there might an issue appearing in production environment due to mostly environment misconfiguration (most frequent) or due to missing dependencies or missing libraries. (It's not the issue with the code but the issue is with infrastructure and environment.)

  2. How Docker solves this problem: In Docker we are shipping everything with out dependencies, libraries, application code and everything that a build required to execute the code including the OS image, so then it works on production environment. (So here likely any chances to fail due to any miss-alignment.)

2. What is a Container and Docker.

  1. Container: A Container is an isolated environment which has configuration libraries, application code, runtime environment and dependencies in it. It is like a Lightweight Sandbox Environment, since it contains only the needful resources to run over application and not the whole operating system resources.

  2. Docker: Docker is a platform which runs this containers and executes the tasks. It is used to Build, Ship and Run the containers. (A tool which provides a medium to execute the code.)

3. Container and Virtual Machine.

  1. Container: A Containers are like Shared Infrastructure but Isolated Environments. It contains all application code, binaries, dependencies and OS with it. It is like flats in the building where each flat is a docker image with it's resources and can communicate with each other with authentication and authorization.

  2. Virtual Machine.: It is a software emulation of a physical machine which allows multiple operating system to run on a single physical machine. It is isolated from each other. VM are an Isolated Infrastructure. It also contains the application code, binaries, dependencies etc. It is like a Bungalow where only one family resides. This Bungalow has 6 bedrooms but the family requires only 3 bedrooms, so the rest 3 bedrooms are of no use.

Containers (very less resource wastage.) Virtual Machine(very high resource wastage.)

4. Virtualization

It allows us to run multiple Operating System instances concurrently on a single computer.

5. Hypervisor

It is used for running multiple Virtual Machine on a single Operating System.

6. Container engine

It is used to run multiple Container instances on a single Operating System.

7. Simple Docker flow

  • Create a Dockerfile.yaml
  • Write a set of instruction of the environment, binaries, application code, runtime in the yaml file.
  • Build the docker image with build command.
  • Push it to the Docker-Hub (Registry to store docker image.)
  • Pull onto any OS or environment where we want to work like on development, test or production.
  • Run the Image Instance.

9. Conclusion

Containers have revolutionized the way we develop, ship, and deploy applications by addressing several critical challenges associated with traditional environments. They provide consistency across different stages of development, testing, and production, eliminating the common issues of environment misconfiguration and missing dependencies. Docker, as a leading containerization platform, facilitates the creation, distribution, and execution of containers, ensuring that applications run seamlessly across various environments.

Containers offer a lightweight, isolated environment that includes everything needed to run an application, without the overhead of a full-fledged operating system, as seen in virtual machines. This results in more efficient use of resources and faster deployment times. Virtual machines, while still useful, tend to be more resource-intensive and less flexible compared to containers.

Virtualization and containerization both allow for multiple instances of operating systems or applications to run concurrently on a single physical machine. However, containers, managed by a container engine like Docker, offer a more streamlined and resource-efficient approach compared to virtual machines managed by a hypervisor.

The Docker workflow is straightforward: define the environment and application requirements in a Dockerfile, build the image, push it to a registry, and then pull and run the image on any desired environment. This process ensures that applications can be consistently replicated and scaled across various platforms.

In summary, Docker and containerization provide a modern, efficient, and scalable solution to the challenges of application deployment, making it easier to develop, test, and deploy applications with minimal resource wastage and maximum portability.

10. Connect with Me.

Linkedin [ linkedin.com/in/het-patel-0407bb1b7 ] Twitter [ x.com/Het46022536 ]

Happy coding and always open to learning new things!