Ayush Goti
Jun 7, 2024
•
7 Min
TABLE OF CONTENTS
Share
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.
A Dockerfile 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 Dockerfile. The build command is used to build an image from the Dockerfile. You can use the -f flag with d0cker build to point to a Dockerfile anywhere in your file system.
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.
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.
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.
Docker was born to solve several key challenges in software development and deployment:
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.
Aspect | Docker | Virtual Machine |
---|---|---|
Isolation | Uses containerization for isolation. | Uses hardware abstraction for isolation. |
Overhead | Minimal overhead, shares OS kernel. | Higher overhead, runs separate OS instances. |
Performance | Generally better performance. | Slightly lower performance due to abstraction. |
Resource Usage | More efficient resource usage. | May consume more resources due to OS overhead. |
Portability | Highly portable across environments. | Less portable, dependent on specific VM type. |
Startup Time | Very fast startup times. | Longer startup times due to booting an OS. |
Security | Limited attack surface, but relies on host OS security. | Higher security due to complete isolation. |
Scaling | Easier scaling with container orchestration tools. | Scaling requires more resources and setup. |
Use Cases | Ideal for microservices and lightweight applications. | Suitable for applications needing complete OS environments. |
Management | Simplified management with Dockerfiles and D0cker Compose. | More complex management with VM images and configurations. |
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.
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.
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 containerised 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.
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.
Step 3 :- I used nginx as per my application requirement, you can change dockerfile as per your requirement.
Step 4 :- Then I build docker with command “sudo docker build -t myapp .”.
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.
Step 6 :- After running the container I can access my application on “localhost:8080”.
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….
Share
Get free guidance from certified experts or build tailored strategies with our team now.