<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Docker]]></title><description><![CDATA[Docker documentation is a comprehensive guide for using Docker, covering installation, configuration, and best practices for managing containerized applications]]></description><link>https://manasi09.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Thu, 22 Oct 2026 15:42:52 GMT</lastBuildDate><atom:link href="https://manasi09.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Master Docker with This Beginner's Guide]]></title><description><![CDATA[Prerequisites Create an Oracle VM on Windows, an Azure VM, or an AWS EC2 instance on Amazon. If you are using a Mac, create a VM as it will be easy to…]]></description><link>https://manasi09.hashnode.dev/master-docker-with-this-beginners-guide</link><guid isPermaLink="true">https://manasi09.hashnode.dev/master-docker-with-this-beginners-guide</guid><category><![CDATA[Docker]]></category><dc:creator><![CDATA[Manasi]]></dc:creator><pubDate>Tue, 24 Sep 2024 02:49:29 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1725434369144/9fae966b-850e-452c-85ae-3844c903e814.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Prerequisites</p>
<ol>
<li><p>Create an Oracle VM on Windows, an Azure VM, or an AWS EC2 instance on Amazon. If you are using a Mac, create a VM as it will be easy to understand and practice..</p>
</li>
<li><p>I used an Amazon free tier account to create an EC2 instance named Docker-appserver with the Debian operating system. It is a T2.micro instance type with 8GB of storage, and it allows SSH and HTTPS traffic.</p>
<p> <strong>Virtual Machine, Containers, and Docker</strong></p>
</li>
</ol>
<p><strong>Virtual machine:</strong> It's a logical separation that has its own operating system, and applications can be hosted on it. If virtual machines were working fine, then why do we have to move towards Containerization?</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1725435641659/2aea6950-dc52-4e70-99c1-7a6f9d26d0cf.png" alt class="image--center mx-auto" /></p>
<p><strong>Containerization</strong> was introduced to efficiently use resources like CPU and RAM at the organizational level, where multiple servers are hosted in a lab and are often idle. Then there was an advancement in technology that led to the introduction of the <strong>hypervisor, which is software that uses the concept of Virtualization</strong>, allowing the creation of many VMs on a single physical server.</p>
<p>Hypervisor examples: <strong>KVM, Microsoft Hyper-V, and VMware vSphere</strong></p>
<p>The issue with virtual machines is that you can't easily scale resources up or down as needed. This problem is solved by containers. Containers can be created on physical servers like DELL or HP servers by installing an OS and then hosting the container. Alternatively, you can use VMs or EC2 instances on cloud provider servers.</p>
<p><strong>Architecture of Containers:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1726411729644/e7bad423-d40f-4856-96ca-79169fe50c5f.png" alt class="image--center mx-auto" /></p>
<p>A container is lightweight because it only includes a base image with the application, libraries, and minimal system dependencies, using shared libraries and resources from the host operating system which it is running on.</p>
<p>» A container needs logical isolation (system dependencies) from containers to avoid the risk of hacking or compromising the security of the organization.The following files and folders are unique to each container and cannot be shared.</p>
<h3 id="heading-files-and-folders-in-containers-base-images">Files and Folders in containers base images</h3>
<p>/bin: contains binary executable files, such as the ls, cp, and ps commands.</p>
<p>/sbin: contains system binary executable files, such as the init and shutdown commands.</p>
<p>/etc: contains configuration files for various system services.</p>
<p>/lib: contains library files that are used by the binary executables.</p>
<p>/usr: contains user-related files and utilities, such as applications, libraries, and documentation.</p>
<p>/var: contains variable data, such as log files, spool files, and temporary files.</p>
<p>/root: is the home directory of the root user.</p>
<h3 id="heading-files-and-folders-that-containers-use-from-host-operating-system">Files and Folders that containers use from host operating system</h3>
<p>The host's file system: Docker containers can access the host file system using bind mounts, which allow the container to read and write files in the host file system.</p>
<p><strong>Networking stack:</strong> The host's networking stack is used to provide network connectivity to the container. Docker containers can be connected to the host's network directly or through a virtual network.</p>
<p><strong>System calls:</strong> The host's kernel handles system calls from the container, which is how the container accesses the host's resources, such as CPU, memory, and I/O.</p>
<p><strong>Namespaces</strong>: Docker containers use Linux namespaces to create isolated environments for the container's processes. Namespaces provide isolation for resources such as the file system, process ID, and network.</p>
<p><strong>Control groups (cgroups)</strong>: Docker containers use cgroups to limit and control the amount of resources, such as CPU, memory, and I/O, that a container can access.</p>
<p><em>"The beauty of containers is that if a container is idle, it will not use any resources from the kernel and will let other containers use them."</em></p>
<p><mark>Docker is </mark> <strong><mark>an open-source containerization platform that helps developers build, test, and deploy applications quickly.</mark> Basically Containerization is a concept or technology that Docker Implements.</strong></p>
<p>Why Docker is so popular?</p>
<ol>
<li><p><strong>Portability:</strong> Docker will facilitates the developers in packaging their applications with all dependencies into a single lightweight containers. It facilities in ensuring the consistent performance across the different computing environments.</p>
</li>
<li><p><strong>Reproducibility:</strong> Docker container ensures software setup running consistently on production, testing and development environments.</p>
</li>
<li><p><strong>Efficiency:</strong> Docker through its container based architectutre ensures optimium resource utilization. Can run mutliple conatiners on a single machine.</p>
</li>
<li><p><strong>Scalability:</strong></p>
<h3 id="heading-archiecture-of-docker"><strong>Archiecture of Docker:</strong></h3>
<p> Docker uses a client-server architecture. The Docker client communicates with the Docker daemon, which builds, runs, and distributes Docker containers. The Docker client can run on the same system as the daemon or connect to it remotely. They interact using a REST API over a UNIX socket or a network. Docker images or containers are then pushed to a registry.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1726411103947/39105fca-b904-4fbf-bc87-84cb37652759.png" alt class="image--center mx-auto" /></p>
</li>
</ol>
<p><strong>Docker Daemon:</strong> It 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 Docker.</p>
<p><strong>Docker Client:</strong> The main objective of the docker client is to provide a way to direct the pull of images from the docker registry and run them on the docker host. The common commands which are used by clients are <strong>docker build, docker pull,</strong> and <strong>docker run.</strong></p>
<p><strong>Docker Host:</strong> A Docker host is a type of machine that is responsible for running more than one container. It comprises the Docker daemon, Images, Containers, Networks, and Storage</p>
<p><strong>Key Components of Docker</strong></p>
<p>The following are the some of the key components of Docker:</p>
<ul>
<li><p><strong>Docker Engine:</strong> It is a core part of docker, that handles the creation and management of containers.</p>
</li>
<li><p><strong>Docker Image:</strong> It is a read-only template that is used for creating containers, containing the application code and dependencies.</p>
</li>
<li><p><strong>Docker Hub:</strong> It is a cloud based repository that is used for finding and sharing the container images.</p>
</li>
<li><p><strong>Dockerfile:</strong> It is a script that containing instructions to build a docker image.</p>
</li>
<li><p><strong>Docker Registry</strong> : It is a storage distribution system for docker images, where you can store the images in both public and private modes</p>
</li>
</ul>
<p><strong>Lifecycle of a Docker</strong>:</p>
<p>There are different stages when we create a Docker container which is known as Docker Container Lifecycle. Some of the states are:</p>
<ul>
<li><p><strong>Created</strong>: A container that has been created but not started</p>
</li>
<li><p><strong>Running</strong>: A container running with all its processes</p>
</li>
<li><p><strong>Paused</strong>: A container whose processes have been paused</p>
</li>
<li><p><strong>Stopped</strong>: A container whose processes have been stopped</p>
</li>
<li><p><strong>Deleted</strong>: A container in a dead state</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1726330152313/5d5cdfb7-6d38-4cc3-80e6-a15a5ee24c93.jpeg" alt class="image--center mx-auto" /></p>
<p><strong>Install Docker on EC2 instance:</strong></p>
<p>step1: connect to EC2 instance with mobaxterm or any other terminal with SSH KEY.</p>
<p>step2: Run the sudo apt-get update command</p>
<p>step3: sudo apt install <a target="_blank" href="http://docker.io">docker.io</a> -y</p>
<p>» Follow the link : <a target="_blank" href="https://docs.docker.com/engine/install/">https://docs.docker.com/engine/install/</a></p>
<p>step4: verification of docker is installed, run “sudo systemctl status docker”</p>
<p>step5: Add ubuntu user or any other user to a docker group to access docker via non-root user.</p>
<p>» sudo usermod -aG docker ubuntu</p>
<p>step5: Logout of ec2 Instance and login back.</p>
<p><strong>Docker Network:</strong></p>
<p>Docker Networking allows you to create a Network of Docker Containers managed by a master node called the manager. Containers inside the Docker Network can talk to each other by sharing packets of information.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1727027092266/28b7f6a1-28c4-491d-843c-a46ab6f41a29.png" alt class="image--center mx-auto" /></p>
<p>Let’s first understand how a container talks to the host: The host has an Eth0 interface with an x.x.x.x subnet, and the container also has an Eth0 interface with a different subnet.</p>
<p>1. Docker creates a virtual interface (VETH) called Bridge networking to communicate with the host, but Bridge networking is not the only method; there are many ways Docker can commuincate with host.</p>
<ol start="2">
<li><p>The second method is HOST networking. In this method, containers (Docker) will directly bind to the ETH0 interface of your host operating system, using the same subnet. Disadvantage is about security as complete OS network is the same as the containers.</p>
</li>
<li><p>Overlay networking is used in Kubernetes and Docker Swarm for multiple Docker containers.</p>
</li>
<li><p>If you want to isolate a container, you can create a virtual bridge separately for a container using the docker network command and use docker run custom network name to create a Docker container.</p>
<h3 id="heading-drawback-of-docker"><strong>Drawback of Docker</strong>:</h3>
<ol>
<li><p>In Docker, Docker Engine is a single point of failure. If the engine stops working, all Docker containers will stop.</p>
</li>
<li><p>As a Docker Image is built from a Dockerfile, it creates multiple layers that occupy huge space.</p>
</li>
<li><p>The Docker daemon runs with root permission, which can cause vulnerability issues.</p>
</li>
<li><p>Imagine there is a container running on an Nginx image, and user logging, authentication, and information are stored in a log file needed for the company’s security audit. If the container goes down, the log file gets deleted because containers are “<strong>ephemeral by nature”</strong> and don't have a file system by default. All resources are used of the kernel or host OS, so it frees up the resources if the container is deleted.</p>
</li>
<li><p>If two containers need to communicate, with one acting as the backend sending files to the frontend to update dynamic content, and the backend container goes down, there is no persistent storage. The frontend will only have the last data sent by the backend, which can cause issues in the application.</p>
</li>
<li><p>A container can access the mount path from the host, but if there is a specific path on the host outside of the mount point, then Docker cannot access it.</p>
</li>
</ol>
</li>
</ol>
<p>    Bind mounts and Volumes:</p>
<p>    Bind mounts allow you to link a directory or folder inside the container to one on the host. If the container goes down, the next container will still be connected to the host's directory where all the files are stored. This way, even if your container stops, your data remains safe.</p>
<p>    Volumes also work like bind mounts but have a better lifecycle. Using the Docker CLI, you can create volumes and attach them to any number of containers without specifying a particular path to the file or directory. You can create the volumes on any external sources like Host, EC2, S3 etc.,</p>
]]></content:encoded></item></channel></rss>