Docker : The Engine Behind Modern Infrastructure

Ayush Goti

Ayush Goti

Jun 7, 2024

7 Min

TABLE OF CONTENTS

  1. Introduction
  2. Why was D0cker Born?
  3. D0cker vs Virtual Machine
  4. Skeleton
  5. What is D0cker Daemon?
  6. What are use cases?
  7. How to build a Container?
  8. Conclusion

Introduction

It is a tool that helps developers package, ship, and run applications in lightweight, portable containers. These containers hold everything an application needs to run, making it easy to move and deploy software across different environments. It provides an efficient way to build, ship, and deploy software, making the development process smoother and more consistent across different environments.

Docker

Docker File

A Docker file is a text document that contains commands that are used to assemble an image. We can use any command that call on the command line. Images are built automatically by reading the instructions from the Docker file. The build command is used to build an image from the Docker file. You can use the -f flag with d0cker build to point to a Docker file anywhere in your file system.

Docker Engine

The Engine is the core component of D0cker. It is responsible for building, running, and managing containers. It consists of a server and a command-line interface (CLI) tool that allows users to interact with D0cker.

Docker Images

A image is like a pre-packaged lunch box containing everything your software needs to run. It includes the code, tools, and other stuff your software requires. When you want to run your software, you use this lunchbox to create a container, which is like a lunchbox in use. This makes it easy to move your software around and run it on different computers.

Docker Container

A container is a lightweight, portable, and self-sufficient software package that contains everything needed to run a piece of software, including the code, runtime, system tools, libraries, and settings. Containers are built from images, which are essentially snapshots of a filesystem that include all the necessary dependencies to run an application. Containers use containerization technology to isolate the application and its dependencies from the underlying system, making them highly portable across different environments.

Why was D0cker Born?

Why-was-docker-Born.jpg

Docker was born to solve several key challenges in software development and deployment:

  • Consistency Across Environments :- Developers often face issues where their code works on one computer but fails on another due to differences in operating systems, libraries, or configurations. It provides a solution by encapsulating applications and their dependencies into containers, ensuring consistency across different environments.
     
  • Dependency Management :- Traditional software deployment involves installing and configuring dependencies manually, which can be time-consuming and error-prone. It simplifies dependency management by packaging applications with all their dependencies, making it easier to deploy and manage software.
     
  • Isolation and Resource Efficiency :- Containers provide lightweight, isolated environments for running applications. Unlike traditional virtual machines, which require a separate operating system for each instance, Containers share the host system’s kernel, resulting in better resource utilization and faster startup times.
     
  • Portability :- Containers are portable and can run on any system that supports D0cker, regardless of the underlying infrastructure. This portability enables developers to build, test, and deploy applications consistently across different environments, from local development machines to production servers and the cloud.
     
  • Streamlining Development Workflows :- It simplifies the development workflow by providing tools for building, testing, and deploying applications in containers. Continuous integration/continuous deployment (CI/CD) pipelines can be built using d0cker to automate the testing and deployment process, leading to faster release cycles and improved developer productivity.


Overall, It was invented to revolutionize the way software is developed, shipped, and run by providing a standardized platform for containerization and enabling greater efficiency, portability, and consistency in software development and deployment workflows.

D0cker vs Virtual Machine

D0cker vs Virtual Machine

AspectDockerVirtual Machine
IsolationUses containerization for isolation.Uses hardware abstraction for isolation.
OverheadMinimal overhead, shares OS kernel.Higher overhead, runs separate OS instances.
PerformanceGenerally better performance.Slightly lower performance due to abstraction.
Resource UsageMore efficient resource usage.May consume more resources due to OS overhead.
PortabilityHighly portable across environments.Less portable, dependent on specific VM type.
Startup TimeVery fast startup times.Longer startup times due to booting an OS.
SecurityLimited attack surface, but relies on host OS security.Higher security due to complete isolation.
ScalingEasier scaling with container orchestration tools.Scaling requires more resources and setup.
Use CasesIdeal for microservices and lightweight applications.Suitable for applications needing complete OS environments.
ManagementSimplified management with Dockerfiles and D0cker Compose.More complex management with VM images and configurations.

 

Skeleton

Docker architecture

The image illustrates the Docker architecture, showcasing the key components and their interactions. At the center is the Engine, responsible for managing containers and providing a runtime environment. Docker client communicates with the Engine through a REST API, enabling users to interact with D0cker using commands. Images are stored in a registry, such as D0cker Hub, and pulled by the Engine to create containers. Containers run isolated from each other and the host system, ensuring consistency and security. Finally, orchestration tools like D0cker Swarm or Kubernetes can be used to manage and scale containerized applications across multiple hosts.

What is D0cker Daemon?

Daemon manages all the services by communicating with other daemons. It manages docker objects such as images, containers, networks, and volumes with the help of the API requests of D0cker. Daemon is a background process that runs on the host machine and manages Docker objects, such as containers, images, networks, and volumes. It acts as the intermediary between the D0cker client and the underlying Linux kernel features that enable containerization.

What are use cases?

d0cker engine

In this scenario, I have a d0cker engine in my host operating system, in docker i have one application which has different modules like Login, Forgot Password, Dashboard etc.

In this application i have containerized modules in separate containers, it means each container has its own module, in this case whenever any module is corrupted or destroyed remaining modules will not be affected it will run normally.

How to build a Container?

Step 1 : I have created a directory with “mkdir” command and give name of directory “myapp”, then i entered in “myapp” directory with “cd” command, then i created one html file “index.html” with text “Hello, Team Certbar.”

Step 2 : After creating the html file I created a “Dockerfile” with the “touch” command, then edited the dockerfile with “vi” command.

01-1-1536x546.jpg

Step 3 :- I used nginx as per my application requirement, you can change dockerfile as per your requirement.

02-1536x131.jpg
Step 4 :- Then I build docker with command “sudo docker build -t myapp .”.

04-1536x498.jpg

Step 5 :- After completion of the built i run my docker application with command “sudo docker run -p 8080:80 myapp”, in this command i bind my host port 8080 with the container port 80, it means that any traffic sent to port 8080 on the host will be forwarded to port 80 within the container.

05-1536x638.jpg

Step 6 :- After running the container I can access my application on “localhost:8080”.


06-1536x263.jpg

Conclusion

In conclusion, It simplifies software development by allowing developers to package their applications and dependencies into containers, making them easy to deploy and run consistently across different environments.

In short, It isn’t just a tool – it’s changing the game in how we build software, making things simpler, faster, and more exciting for developers everywhere.

“Transforming complexity into simplicity, one container at a time – that’s Docker.”

That’s all for now until next time….

blue-icontext.jpgimages-removebg-preview.png

Ayush Goti
Ayush GotiJr. Security Analyst
linkedin

Ayush Goti, Certbar Security’s adept Penetration Tester, blends academic excellence with practical skills in cybersecurity. Parul University graduate in Cyber Security and Forensics.

Share

Share to Microsoft Teams

Take complete control of your cybersecurity

Get free guidance from certified experts or build tailored strategies with our team now.

Header Logo

Attack. Defend. Comply. Privacy.

InstagramTwitterLinkedinFacebook

Register with:

Linkedin

Services

    Penetration TestingAI SecurityData PrivacyManaged Security ServicesComplianceConfiguration Assessment
Copyright © 2019 - 2024 Certbar Security Pvt. Ltd. All rights reserved.