<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sunil yadav on Medium]]></title>
        <description><![CDATA[Stories by Sunil yadav on Medium]]></description>
        <link>https://medium.com/@ysunil24359?source=rss-2b1a75c2a89c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*M6vK2IeujCzG_OHt</url>
            <title>Stories by Sunil yadav on Medium</title>
            <link>https://medium.com/@ysunil24359?source=rss-2b1a75c2a89c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 04:16:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ysunil24359/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Docker: A Begineer Guide]]></title>
            <link>https://medium.com/@ysunil24359/docker-a-begineer-guide-297c562d90cf?source=rss-2b1a75c2a89c------2</link>
            <guid isPermaLink="false">https://medium.com/p/297c562d90cf</guid>
            <category><![CDATA[docker-image]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[dockerfile-best-practice]]></category>
            <category><![CDATA[dockerfiles]]></category>
            <dc:creator><![CDATA[Sunil yadav]]></dc:creator>
            <pubDate>Sat, 21 Jan 2023 10:36:07 GMT</pubDate>
            <atom:updated>2023-01-21T10:36:07.139Z</atom:updated>
            <content:encoded><![CDATA[<p>“Docker: A Beginner’s Guide” would be a book that is designed to help people who are new to Docker to understand the basics of the technology and how to use it. The book would provide a comprehensive introduction to the key concepts and terminology used in Docker, as well as step-by-step instructions for setting up a Docker environment and running containers.</p><p>The book would begin with an introduction to Docker and why it is an important technology. It would explain the key concepts and terminology used in Docker, including images, containers, and volumes. It would also discuss how Docker differs from traditional virtualization and why it is a more efficient and effective way to create and manage virtual environments.</p><p>Next, the book would cover the process of setting up a Docker environment, including instructions for installing Docker on various operating systems and configuring the settings. It would also cover the basics of creating and managing Docker images, including how to build, tag, and push images to a registry.</p><p>Once the environment is set up, the book would guide the reader on how to run containers. It would provide step-by-step instructions for creating and starting containers, configuring container settings, and stopping and removing containers. It would also cover how to use volumes and networks to manage data and connect containers together.</p><p>The book would also cover some advanced techniques in Docker, including how to use Docker Compose to manage multi-container applications, best practices for container security and how to deploy Docker in production environments.</p><p>Finally, the book would provide a conclusion that summarizes the key concepts and techniques covered in the book, and provides additional resources for further learning, as well as future developments in Docker technology.</p><h4>Chapter 1: Introduction to Docker</h4><p>Docker is a platform that allows developers to easily create, deploy, and run applications in containers. Containers are lightweight, portable, and self-sufficient environments that can run on any system that supports Docker, regardless of the underlying operating system or infrastructure.</p><p>Docker enables developers to package their application and its dependencies into a single container, which can then be easily deployed and run on any system that has the Docker runtime installed. This makes it easy to move applications between different environments, such as from development to production, and ensures that the application will run consistently across different systems.</p><p>Docker uses a containerization approach, which is different from traditional virtualization. Instead of creating a virtual machine that runs on top of a host operating system, Docker creates a container that shares the host’s kernel. This makes Docker containers lightweight, fast, and efficient.</p><p>Docker also includes a powerful set of tools for managing and orchestrating containers. It includes a command-line interface for managing containers, a container registry for sharing images, and a set of APIs for automating the deployment and scaling of containers.</p><p>In short, Docker is a powerful and flexible platform that makes it easy to create, deploy, and run applications in containers. It enables developers to build, test, and deploy their applications in a consistent and portable way, and helps to simplify the process of moving applications between different environments.</p><h4>Why docker is Important?</h4><p>Docker is important for several reasons:</p><ol><li>Portability: Docker allows developers to package their application and its dependencies into a single container, which can then be easily deployed and run on any system that has the Docker runtime installed. This makes it easy to move applications between different environments, such as from development to production, and ensures that the application will run consistently across different systems.</li><li>Isolation: Docker allows developers to easily isolate their applications from the underlying infrastructure, making it easier to test and deploy their code in different environments without worrying about conflicting dependencies or configurations.</li><li>Scalability: Docker provides a set of tools for managing and orchestrating containers, which enables teams to easily scale, distribute, and manage their applications. This makes it easier to deploy and manage large and complex applications.</li><li>Resource Utilization: Docker allows multiple applications to run on a single machine, each in its own container, which makes more efficient use of resources.</li><li>Consistency: Docker allows for consistency across development, testing, and production environments, avoiding “works on my machine” issues.</li><li>Microservices Architecture: Docker is an excellent tool for implementing a microservices architecture, as it allows developers to easily break down a monolithic application into smaller, more manageable services that can be deployed, scaled, and managed independently.</li><li>Community Support: Docker has a large and active community, which provides plenty of resources, tutorials and best practices for using the platform.</li></ol><p>Docker is increasingly used in software development and IT operations, allowing faster development, testing and deployment of applications, making it a key technology in DevOps.</p><h4>Key concepts and terminology</h4><p>Docker key concepts and terminology include:</p><ul><li>Containers: Lightweight, portable environments that contain everything an application needs to run, including the code, runtime, system tools, and libraries.</li><li>Images: Templates used to create containers. They can be built from source code, or pulled from a container registry.</li><li>Docker Engine: The underlying technology that runs the containers. It includes a daemon process that runs on the host machine, a REST API, and a command-line interface (CLI)</li><li>Docker Hub: A public registry where users can store and share their images.</li><li>Docker Compose: A tool for defining and running multi-container applications.</li><li>Volumes: A way to store data outside of the container file system, which allows data to persist after the container is deleted.</li><li>Networks: A way to connect containers together and to the host machine, allowing them to communicate with each other.</li><li>Dockerfile: A script that contains instructions for building an image.</li><li>Docker Swarm: A native clustering for Docker, which allows to create and manage a swarm of Docker Engines.</li></ul><h4>How Docker differs from traditional virtualization</h4><p>Docker differs from traditional virtualization in a few key ways:</p><ol><li>Containers vs Virtual Machines: Docker uses a containerization approach, whereas traditional virtualization uses virtual machines (VMs). A container is a lightweight, portable, and self-sufficient environment that shares the host’s kernel, whereas a VM is a full-fledged virtualized environment that runs on top of a host operating system.</li><li>Resource Utilization: Docker containers are more lightweight and efficient than VMs, allowing for better resource utilization. Multiple containers can run on a single machine, whereas each VM requires its own operating system and resources.</li><li>Portability: Docker containers are designed to be portable and can run on any system that supports Docker, regardless of the underlying operating system or infrastructure. This makes it easy to move applications between different environments. VM’s are less portable as they are tightly coupled with the underlying host operating system.</li><li>Isolation: Docker allows for better isolation between applications, as each container runs in its own isolated environment. VMs offer isolation as well, but at a higher cost in terms of resources and complexity.</li><li>Management: Docker provides a set of tools for managing and orchestrating containers, which allows for easy scaling, distribution, and management of applications. Managing VMs is more complex, and requires additional tools and processes.</li></ol><p>In summary, Docker is a more efficient and effective way to create and manage virtual environments, it provides better resource utilization, portability, isolation and management of applications, while traditional virtualization is more complex and resource-intensive.</p><h4>Chapter 2: Setting up a Docker Environment</h4><p>In this chapter, we will cover the process of setting up a Docker environment on your local machine with examples. We will start by installing the Docker runtime, and then move on to configuring Docker settings and creating and managing Docker images.</p><ol><li>Installing Docker: The first step in setting up a Docker environment is to install the Docker runtime on your local machine. Docker is supported on a wide range of operating systems, including Windows, MacOS, and Linux. The installation process will vary depending on your operating system, but it generally involves downloading the Docker installer and running it.</li></ol><p>For example, on Ubuntu, you can install Docker with the following commands:</p><pre>sudo apt-get update<br>sudo apt-get install docker.io</pre><p>On Windows, you can download the Docker Desktop installer from the official website and run the installer.</p><ol><li>Configuring Docker Settings: Once Docker is installed, you can start configuring the settings to suit your needs. This can be done through the Docker daemon configuration file or the Docker CLI. The most common settings to configure include the amount of memory and CPU allocated to the Docker engine, the storage driver, and the logging options.</li></ol><p>For example, you can configure the amount of memory allocated to Docker with the following command:</p><pre>sudo nano /etc/docker/daemon.json</pre><p>And add the following line:</p><pre>{ &quot;memory&quot;: 2147483648 }</pre><ol><li>Creating and Managing Docker Images: Docker images are the building blocks of containers. They are used to create new containers, and can be built from source code or pulled from a container registry. The Docker CLI provides a set of commands for creating, managing, and working with images. You can use the “docker build” command to create a new image from a Dockerfile, or the “docker pull” command to download an image from a registry.</li></ol><p>For example, to build an image from a Dockerfile in the current directory, you can run the following command:</p><pre>docker build -t myimage .</pre><ol><li>Setting up a Private Registry: If you need to store your images in a private registry, it can be set up using the Docker registry. It could be installed on a local server or you can use a cloud service like AWS, GCP, or Azure.</li></ol><p>For example, you can use the official Docker registry image to start a registry on your local machine with the following command.</p><pre>docker run -d -p 5000:</pre><p><strong>Installing Docker on various operating systems</strong></p><p>Docker is supported on a wide range of operating systems, including Windows, MacOS, and Linux. The installation process will vary depending on the operating system you are using, but the basic steps are similar across all platforms.</p><ol><li>Windows:</li></ol><ul><li>Download the Docker Desktop installer from the official website and run the installer.</li><li>Once the installation is complete, you can launch Docker from the Start menu.</li><li>You can verify the installation by running the following command in a command prompt:</li></ul><pre>docker --version</pre><ol><li>MacOS:</li></ol><ul><li>Download the Docker Desktop installer from the official website and run the installer.</li><li>Once the installation is complete, you can launch Docker from the Applications folder.</li><li>You can verify the installation by running the following command in a terminal:</li></ul><pre>docker --version</pre><ol><li>Ubuntu:</li></ol><ul><li>Add the official Docker repository to your system with the following command:</li></ul><pre>sudo apt-get install apt-transport-https ca-certificates curl software-properties-common<br>curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -<br>sudo add-apt-repository &quot;deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable&quot;</pre><ul><li>Install Docker with the following command:</li></ul><pre>sudo apt-get update<br>sudo apt-get install docker-ce</pre><ul><li>You can verify the installation by running the following command in a terminal:</li></ul><pre>docker --version</pre><p>These are just examples of how to install Docker on some popular operating systems, depending on your operating system, the installation process may vary. you should always refer to the official documentation for the most up-to-date and accurate instructions.</p><p><strong>Configuring docker settings:</strong></p><p>Docker settings can be configured to suit your specific needs. The settings can be managed through the Docker daemon configuration file or the Docker CLI. The most common settings to configure include the amount of memory and CPU allocated to the Docker engine, the storage driver, and the logging options.</p><ol><li>Memory and CPU allocation: Docker uses the host machine’s resources to run containers. You can configure the amount of memory and CPU allocated to the Docker engine by editing the daemon.json file. For example, on Ubuntu, you can configure the amount of memory allocated to Docker with the following command:</li></ol><pre>sudo nano /etc/docker/daemon.json</pre><p>And add the following line:</p><pre>{ &quot;memory&quot;: 2147483648 }</pre><ol><li>Storage Driver: Docker supports multiple storage drivers, each with its own advantages and disadvantages. You can choose a storage driver that best suits your needs by editing the daemon.json file. For example, you can configure Docker to use the overlay2 storage driver with the following command:</li></ol><pre>{ &quot;storage-driver&quot;: &quot;overlay2&quot; }</pre><ol><li>Logging options: You can configure logging options for Docker to suit your specific needs by editing the daemon.json file. For example, you can configure Docker to send logs to a remote syslog server with the following command:</li></ol><pre>{ &quot;log-driver&quot;: &quot;syslog&quot;, &quot;log-opt&quot;: { &quot;syslog</pre><p><strong>Creating and managing Docker images</strong></p><p>Docker images are the building blocks of containers. They are used to create new containers, and can be built from source code or pulled from a container registry. The Docker CLI provides a set of commands for creating, managing, and working with images.</p><ol><li>Creating an image: You can use the “docker build” command to create a new image from a Dockerfile. A Dockerfile is a script that contains instructions for building an image. For example, you can build an image from a Dockerfile in the current directory with the following command:</li></ol><pre>docker build -t myimage .</pre><ol><li>Listing images: You can use the “docker images” command to list all the images on your local machine. The command will display information such as the image ID, repository, and tag. For example, to list all the images on your local machine you can run the following command:</li></ol><pre>docker images</pre><ol><li>Removing an image: You can use the “docker rmi” command to remove an image from your local machine. For example, to remove an image with the ID “abc123”, you can run the following command:</li></ol><pre>docker rmi abc123</pre><ol><li>Pulling an image from a registry: You can use the “docker pull” command to download an image from a registry. For example, to download the latest version of the “nginx” image from Docker Hub, you can run the following command:</li></ol><pre>docker pull nginx</pre><ol><li>Pushing an image to a registry: you can use the “docker push” command to upload an image to a registry. For example, to upload an image with the tag “myimage” to your account on Docker Hub, you can run the following command:</li></ol><pre>docker push myusername/myimage</pre><p>These are just some examples of the basic commands for creating, managing and working with Docker images, and there are many more options and variations available, depending on your needs.</p><h3>Chapter 3: Running Containers</h3><p>Once you have an image, you can use it to create and start a new container. The Docker CLI provides a set of commands for creating, managing, and working with containers.</p><ol><li>Creating a container: You can use the “docker run” command to create a new container from an image. For example, to create a new container from the “nginx” image, you can run the following command:</li></ol><pre>docker run -d -p 80:80 nginx</pre><p>This command will create a new container in detached mode (-d) and map port 80 of the host to port 80 of the container.</p><ol><li>Listing containers: You can use the “docker ps” command to list all the running containers on your local machine. For example, to list all running containers, you can run the following command:</li></ol><pre>docker ps</pre><ol><li>Stopping a container: You can use the “docker stop” command to stop a running container. For example, to stop a container with the ID “abc123”, you can run the following command:</li></ol><pre>docker stop abc123</pre><ol><li>Removing a container: You can use the “docker rm” command to remove a container. For example, to remove a container with the ID “abc123”, you can run the following command:</li></ol><pre>docker rm abc123</pre><ol><li>Inspecting a container: You can use the “docker inspect” command to view detailed information about a container. For example, to view detailed information about a container with the ID “abc123”, you can run the following command:</li></ol><pre>docker inspect abc123</pre><p>These are some examples of basic commands for creating, managing, and working with Docker containers, and there are many more options and variations available, depending on your needs.</p><p>It’s important to note that when you stop a container, its data is not deleted, so you can start it again later. However, if you remove a container, it’s data will be deleted along with the container itself.</p><h4>Configuring container settings:</h4><p>Once a container is created, you can configure various settings to suit your specific needs. The settings can be managed through the Docker CLI or the Docker API.</p><ol><li>Port mapping: You can use the “-p” option of the “docker run” command to map ports between the container and the host. For example, to map port 80 of the host to port 80 of the container, you can run the following command:</li></ol><pre>docker run -d -p 80:80 nginx</pre><ol><li>Environment variables: You can use the “-e” option of the “docker run” command to set environment variables in the container. For example, to set the “myvar” environment variable in the container, you can run the following command:</li></ol><pre>docker run -d -e myvar=value nginx</pre><ol><li>Volumes: You can use the “-v” option of the “docker run” command to mount a volume in the container. For example, to mount the “/data” directory of the host to the “/data” directory of the container, you can run the following command:</li></ol><pre>docker run -d -v /data:/data nginx</pre><ol><li>Networking: You can use the “ — network” option of the “docker run” command to connect a container to a network. For example, to connect a container to the “mynetwork”</li></ol><p><strong>Stopping and removing containers</strong></p><ol><li>Stopping a container: You can use the “docker stop” command to stop a running container. For example, to stop a container with the ID “abc123”, you can run the following command:</li></ol><pre>Copy code</pre><pre>docker stop abc123</pre><p>This command will send a SIGTERM signal to the main process inside the container, waiting for a grace period of 10 seconds before sending a SIGKILL signal.</p><ol><li>Removing a container: You can use the “docker rm” command to remove a container. For example, to remove a container with the ID “abc123”, you can run the following command:</li></ol><pre>docker rm abc123</pre><p>This command will remove the container and any data associated with it.</p><p>It’s important to note that when you stop a container, its data is not deleted, so you can start it again later. However, if you remove a container, it’s data will be deleted along with the container itself.</p><p>You can use the “docker rm” command with the option “-f” to force remove a running container and the option “-v” to remove volumes associated with the container.</p><p>For example, to remove a container with the ID “abc123” along with its volumes, you can run the following command:</p><pre>docker rm -vf abc123</pre><p>This command will remove the container, any data associated with it and all the volumes attached to it.</p><h3>Chapter 4: Docker Volumes and Networks</h3><p>In this chapter, we will cover the concepts of Docker volumes and networks. We will discuss the use cases for volumes and networks and how to create and manage them.</p><ol><li>Docker Volumes: A Docker volume is a way to store data outside of a container’s filesystem. Volumes are useful for storing data that needs to persist even if the container is deleted, such as database files or user-generated content. You can create and manage volumes using the “docker volume” command.</li></ol><p>For example, you can create a new volume named “myvolume” with the following command:</p><pre>docker volume create myvolume</pre><p>You can also use the “-v” option of the “docker run” command to mount a volume in a container. For example, to mount the “myvolume” volume in the “/data” directory of a container, you can run the following command:</p><pre>docker run -d -v myvolume:/data nginx</pre><ol><li>Docker Networks: A Docker network is a way to connect multiple containers together. Networks are useful for creating isolated environments for your application, such as a development, testing, and production environment. You can create and manage networks using the “docker network” command.</li></ol><p>For example, you can create a new network named “mynetwork” with the following command:</p><pre>docker network create mynetwork</pre><p>You can also use the “ — network” option of the “docker run” command to connect a container to a network. For example, to connect a container named “mycontainer” to the “mynetwork” network, you can run the following command:</p><pre>docker run -d --network mynetwork --name mycontainer nginx</pre><p>You can also use the “docker network connect” command to connect a running container to a network, and “docker network disconnect” to disconnect a container from a network</p><p>These are just some examples of basic commands for creating, managing, and working with Docker volumes and networks, and there are many more options and variations available, depending on your needs.</p><p><strong>Understanding volumes and how to use them</strong></p><p>A Docker volume is a way to store data outside of a container’s filesystem. Volumes are useful for storing data that needs to persist even if the container is deleted, such as database files or user-generated content.</p><p>When a container is created, its filesystem is ephemeral, meaning that all changes made to the filesystem will be lost when the container is deleted. However, when you use a volume, the data stored in the volume will persist even if the container is deleted.</p><p>There are two types of volumes in Docker:</p><ol><li>Bind mounts: This type of volume allows you to mount a directory on the host machine into a container. This is useful when you want to share files or directories between the host machine and the container.</li><li>Named volumes: This type of volume is managed by Docker, and it allows you to create a volume with a specific name. Named volumes are useful when you want to share data between multiple containers or when you want to persist data beyond the life of a single container.</li></ol><p>You can use the “docker volume” command to create and manage volumes. For example, you can create a new volume named “myvolume” with the following command:</p><pre>docker volume create myvolume</pre><p>You can also use the “-v” option of the “docker run” command to mount a volume in a container. For example, to mount the “myvolume” volume in the “/data” directory of a container, you can run the following command:</p><pre>docker run -d -v myvolume:/data nginx</pre><p>You can also use the “docker volume inspect” command to see more information about a volume, like the location of the volume in the host and the driver used.</p><p>It’s important to note that volumes can also be used with Docker Compose, which allows you to define and manage multi-container applications</p><p><strong>Creating and managing networks in Docker:</strong></p><p>A Docker network is a way to connect multiple containers together, allowing them to communicate with each other. Networks are useful for creating isolated environments for your application, such as a development, testing, and production environment.</p><p>Docker supports several types of networks, such as bridge, host, and overlay networks. Each type of network has its own advantages and use cases.</p><ol><li>Bridge networks: This is the default network type in Docker and it allows containers to communicate with each other on the same host. Bridge networks are useful for simple use cases, such as a single host development environment.</li><li>Host networks: This type of network allows containers to use the host’s network stack directly. This is useful when you want to share the host’s network configuration with the container.</li><li>Overlay networks: This type of network allows containers to communicate across multiple hosts. This is useful when you want to create a network that spans multiple hosts, such as a swarm or a kubernetes cluster.</li></ol><p>You can use the “docker network” command to create and manage networks. For example, you can create a new network named “mynetwork” with the following command:</p><pre>docker network create mynetwork</pre><p>You can also use the “ — network” option of the “docker run” command to connect a container to a network. For example, to connect a container named “mycontainer” to the “mynetwork” network, you can run the following command:</p><pre>docker run -d --network mynetwork --name mycontainer nginx</pre><p>You can also use the “docker network connect” command to connect a running container to a network, and “docker network disconnect” to disconnect a container from a network.</p><p>You can also use the “docker network inspect” command to see more information about a network, like the driver used, the IPAM configuration, and the list of connected containers.</p><p>It’s important to note that networks can also be used with Docker Compose, which allows you to define and manage multi-container applications and their networks in a single file.</p><p><strong>Linking containers together</strong></p><p>Docker provides a feature called container linking, which allows you to link one container to another. Linking containers allows them to communicate with each other and share environment variables.</p><p>You can use the “ — link” option of the “docker run” command to link a container to another container. For example, to link a container named “webapp” to a container named “database”, you can run the following command:</p><pre>Copy code</pre><pre>docker run -d --name webapp --link database:db nginx</pre><p>This command will create a new container named “webapp” and link it to the “database” container, giving the “webapp” container access to the “database” container’s environment variables.</p><p>When linking containers, the first container’s hostname and IP address will be added to the /etc/hosts file of the second container. So, the second container can communicate with the first container using its hostname.</p><p>When you link containers together, you are creating a secure connection between them, without the need to expose ports.</p><p>It’s important to note that linking is only supported for containers running on the same host, and it’s not recommended for use with swarm or kubernetes clusters. In those cases, you should use overlay networks.</p><h3>Chapter 5: Advanced Docker Techniques</h3><p>In this chapter, we will cover some advanced techniques for working with Docker. We will discuss topics such as container orchestration, logging, and monitoring.</p><ol><li>Container orchestration: Container orchestration is the process of managing and scaling multiple containers. Docker provides built-in orchestration features, such as Docker Compose and Docker Swarm, which allow you to easily create and manage multi-container applications.</li></ol><p>Docker Compose is a tool that allows you to define and run multi-container applications in a single file, while Docker Swarm is a built-in orchestration feature that allows you to create and manage a swarm of Docker nodes.</p><ol><li>Logging: Logging is an important aspect of containerized applications. Docker provides built-in logging features, such as the “docker logs” command, which allows you to view the logs of a container. Additionally, you can use third-party logging solutions, such as Fluentd, Logstash, and ELK stack to collect and analyze logs from your containers.</li><li>Monitoring: Monitoring is the process of collecting and analyzing performance metrics from your containers. Docker provides built-in monitoring features, such as the “docker stats” command, which allows you to view the resource usage of a container. Additionally, you can use third-party monitoring solutions, such as Prometheus and Grafana, to collect and analyze metrics from your containers.</li><li>Security: Security is an important aspect of containerized applications. Docker provides built-in security features, such as user namespaces, which allow you to run a container as a non-root user. Additionally, you can use third-party security solutions, such as AppArmor and SELinux, to secure your containers</li><li>These are just some examples of advanced techniques for working with Docker, and there are many more options and variations available, depending on your needs.</li></ol><p><strong>Using Docker Compose to manage multi-container applications</strong></p><p>Docker Compose is a tool that allows you to define and run multi-container applications in a single file. It provides a simple and easy-to-use syntax for defining and running your applications.</p><p>A Docker Compose file, usually named docker-compose.yml, is a YAML file that defines your application&#39;s services, networks, and volumes. Each service in the file represents a container, and you can define its configuration such as image, environment variables, ports, and volumes.</p><p>An example of a simple docker-compose.yml file for a web application might look like this:</p><pre>version: &#39;3&#39;<br>services:<br>  web:<br>    image: nginx:latest<br>    ports:<br>      - &quot;80:80&quot;<br>    volumes:<br>      - ./web:/usr/share/nginx/html<br>  db:<br>    image: postgres:latest<br>    environment:<br>      - POSTGRES_PASSWORD=mysecretpassword<br>    volumes:<br>      - db-data:/var/lib/postgresql/data<br>volumes:<br>  db-data:</pre><p>This file defines two services, “web” and “db”, both with different configurations. The “web” service is running the latest version of the nginx image and it’s exposing port 80 and mounting a local folder as a volume. The “db” service is running the latest version of the postgres image, it’s setting an environment variable and also mounting a volume.</p><p>Once you have a compose file, you can use the docker-compose command to manage your application. For example, you can use the following command to start your application:</p><pre>docker-compose up</pre><p>This command will start all the services defined in the compose file, creating and running the containers. You can also use the command docker-compose down to stop and remove the containers, volumes and networks created by the up command.</p><p>Docker Compose also allows you to scale your services, to run commands inside the containers, and to manage the state of your application. It’s a powerful tool that makes it easy to manage multi-container applications and their dependencies.</p><p><strong>Best practices for container security</strong></p><ol><li>Run containers as non-root users: By default, containers run as the root user, which can pose a security risk. It’s best practice to run containers as non-root users to limit the potential damage in case a container is compromised.</li><li>Use minimal base images: Using minimal base images can help reduce the attack surface of a container. Minimal base images contain fewer packages and libraries, which means fewer vulnerabilities to exploit.</li><li>Use official images: Official images are images that are maintained by the vendors of the software they contain. Using official images can ensure that you are getting a version of the software that is up-to-date and has passed security audits.</li><li>Keep images and containers up-to-date: Keeping images and containers up-to-date can help ensure that you have the latest security patches and fixes.</li><li>Use a container security scanner: There are several container security scanners available, such as Aqua Security, Sysdig, and Aqua Security, that can scan your images and containers for vulnerabilities.</li><li>Use a container firewall: Using a container firewall can help protect your containers by filtering incoming and outgoing traffic.</li><li>Use secrets management: Avoid storing sensitive information such as passwords, keys, and certificates in plain text in your images or containers. Instead, use a secrets management solution such as HashiCorp Vault, AWS Secrets Manager, Azure Key Vault, etc. to store and manage your secrets.</li><li>Use a security-hardened kernel: A security-hardened kernel can provide additional security features, such as AppArmor or SELinux, to help protect your containers.</li><li>Monitor and Audit: Keep track of the activity in your containers, regularly monitor and audit the logs of your containers, hosts and network to detect any malicious activities or suspicious behavior.</li><li>These are just some examples of best practices for container security in Docker, and there are many more options and variations available, depending on your needs. It’s important to keep in mind that container security is an ongoing process, and you should always be aware of the latest threats and vulnerabilities, and update your security measures accordingly.</li></ol><p><strong>Deploying Docker in production environments</strong></p><ol><li>Use container orchestration tools: To deploy and manage large-scale Docker deployments, it’s recommended to use a container orchestration tool such as Kubernetes, Docker Swarm, or Amazon ECS. These tools provide features such as automatic scaling, load balancing, and self-healing, making it easier to manage and deploy your application in a production environment.</li><li>Use a private registry: To ensure the security of your images and to control access to your images, it’s recommended to use a private registry such as Docker Trusted Registry, or a cloud-based registry such as AWS ECR, or Google Container Registry. This will help you to store and distribute your images securely.</li><li>Use a load balancer: To distribute traffic across multiple containers and to ensure high availability, it’s recommended to use a load balancer such as HAProxy or NGINX. You can also use cloud-based load balancer services such as AWS ELB or Google Cloud Load Balancer.</li><li>Use a monitoring and logging solution: To monitor the performance and health of your application and its infrastructure, it’s recommended to use a monitoring and logging solution such as Prometheus, Grafana, and Elasticsearch.</li><li>Use a security solution: To secure your application and its infrastructure, it’s recommended to use a security solution such as AppArmor or SELinux, or a security scanner such as Aqua Security or Sysdig.</li><li>Use a backup solution: To ensure that you can recover quickly in the event of a disaster, it’s recommended to use a backup solution such as Backup Ninja or BackupPC.</li><li>Use a disaster recovery solution: To ensure that your application is highly available, it’s recommended to use a disaster recovery solution such as Amazon Elastic Container Service for Kubernetes (EKS) or Kubernetes.</li><li>Use a network solution: To ensure that your network is properly configured to handle the traffic between your containers, it’s recommended to use a network solution such as Calico or Weave.</li><li>Use a secrets management solution: To securely store sensitive information such as passwords, keys, and certificates, it’s recommended to use a secrets management solution such as Hashicorp Vault, AWS Secrets Manager, or Azure Key Vault.</li><li>These are just some examples of the best practices and tools to consider when deploying Docker in a production environment. It’s important to keep in mind that deploying in production involves many factors and it’s important to have a solid plan in place for monitoring, scaling, and disaster recovery.</li></ol><h3>Conclusion</h3><p>Docker is a powerful tool that allows you to easily create, deploy, and manage containerized applications. It provides a consistent and portable environment for your applications, making it easier to develop, test, and deploy your applications.</p><p>In this book, we have covered the key concepts and terminology of Docker, including images, containers, networks, and volumes. We have also discussed how to set up a Docker environment, create and manage images and containers, and use Docker Compose to manage multi-container applications.</p><p>We also discussed advanced Docker techniques such as container orchestration, logging, monitoring, and security. And we covered best practices for deploying Docker in production environments, including using container orchestration tools, a private registry, a load balancer, and a monitoring and logging solution.</p><p>Docker is a versatile and powerful tool that can be used in a variety of scenarios, from development and testing to production deployments. By understanding the concepts and best practices discussed in this book, you should now have the knowledge and tools you need to effectively use Docker in your own projects.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=297c562d90cf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cross Site Scripting Intro]]></title>
            <link>https://medium.com/@ysunil24359/cross-site-scripting-intro-abdb432aabc8?source=rss-2b1a75c2a89c------2</link>
            <guid isPermaLink="false">https://medium.com/p/abdb432aabc8</guid>
            <category><![CDATA[cross-site-scripting]]></category>
            <category><![CDATA[xss-attack]]></category>
            <dc:creator><![CDATA[Sunil yadav]]></dc:creator>
            <pubDate>Fri, 20 Jan 2023 02:13:13 GMT</pubDate>
            <atom:updated>2023-01-20T02:13:13.413Z</atom:updated>
            <content:encoded><![CDATA[<p>Cross-Site Scripting (XSS) is a type of web vulnerability that allows an attacker to inject malicious scripts into a web page viewed by other users. This can allow the attacker to steal sensitive information, such as login credentials, or to perform other malicious actions on the victim’s behalf.</p><p>XSS attacks can occur when a web application does not properly validate user input. For example, if a website allows users to post comments and does not properly sanitize the input, an attacker could post a comment containing a malicious script. When other users view the page, the script would be executed, potentially allowing the attacker to steal sensitive information or perform other malicious actions.</p><p>There are two main types of XSS attacks: stored and reflected. In a stored XSS attack, the malicious script is stored on the web server and served to all users who view the affected page. In a reflected XSS attack, the script is included in the victim’s request and is only executed when the victim views the page.</p><p>To prevent XSS attacks, it is important for web developers to properly validate and sanitize user input. This can be done by using a library or framework that automatically escapes user input, or by manually sanitizing input using techniques such as encoding special characters. Additionally, it is important to use a Content Security Policy (CSP) to restrict the types of scripts that can be executed on a website.</p><p>Another important step is to keep all software and frameworks updated, as new vulnerabilities are often discovered and patched.</p><p>In summary, Cross-Site Scripting (XSS) is a type of web vulnerability that allows an attacker to inject malicious scripts into a web page viewed by other users. To prevent XSS attacks, it is important to properly validate and sanitize user input, use a Content Security Policy (CSP) and keep all software and frameworks updated. By taking these steps, web developers can protect their users and ensure the security of their web applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=abdb432aabc8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS API Leaks]]></title>
            <link>https://medium.com/@ysunil24359/aws-api-leaks-ecc3f324ec0a?source=rss-2b1a75c2a89c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ecc3f324ec0a</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[api-leaks]]></category>
            <dc:creator><![CDATA[Sunil yadav]]></dc:creator>
            <pubDate>Fri, 20 Jan 2023 02:10:32 GMT</pubDate>
            <atom:updated>2023-01-20T02:10:32.157Z</atom:updated>
            <content:encoded><![CDATA[<p>AWS API leaks refer to situations where an AWS user accidentally exposes their AWS access keys or secrets, which can allow unauthorized access to the user’s AWS resources. This can happen in a variety of ways, such as through unsecured S3 buckets, insecurely configured IAM roles, or through code that is pushed to a public repository.</p><p>An example of an AWS API leak could be a developer who accidentally pushes their AWS access keys to a public GitHub repository. Anyone with access to the repository would then be able to use those keys to access the developer’s AWS resources, potentially causing significant damage.</p><p>Another example could be a company who is using an S3 bucket to store sensitive data, but has not properly configured the bucket’s access controls. As a result, the bucket is publicly accessible and anyone can download the data stored in it.</p><p>To prevent AWS API leaks, it is important to follow best practices for securing access keys and secrets, such as rotating them regularly, and using multi-factor authentication. Additionally, it is essential to properly configure access controls for all AWS resources, such as S3 buckets and IAM roles.</p><p>AWS also provides several services that can help with the detection and prevention of API leaks, such as Amazon Macie for identifying sensitive data in S3, and AWS Security Hub for aggregating security findings from different AWS services.</p><p>In summary, AWS API leaks can occur when access keys or secrets are exposed, and can allow unauthorized access to the user’s AWS resources. To prevent this, it is important to follow best practices for securing access keys and secrets, and properly configure access controls for all AWS resources. AWS also provides several services to help with the detection and prevention of API leaks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ecc3f324ec0a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlocking the Potential of Big Data with Hadoop: A Beginner’s Guide]]></title>
            <link>https://medium.com/@ysunil24359/unlocking-the-potential-of-big-data-with-hadoop-a-beginners-guide-f6b40a2aff1f?source=rss-2b1a75c2a89c------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6b40a2aff1f</guid>
            <dc:creator><![CDATA[Sunil yadav]]></dc:creator>
            <pubDate>Fri, 20 Jan 2023 02:08:18 GMT</pubDate>
            <atom:updated>2023-01-20T02:08:18.630Z</atom:updated>
            <content:encoded><![CDATA[<p>Hadoop is an open-source framework for storing and processing big data in a distributed environment. It is designed to handle large amounts of data, both structured and unstructured, and enables businesses to gain insights and make data-driven decisions.</p><p>One of the main features of Hadoop is its ability to store and process data on a cluster of commodity hardware. This allows organizations to scale their infrastructure as their data grows, without the need for expensive, specialized hardware. Hadoop also provides a number of tools for data processing, including MapReduce and Pig, which allow developers to write complex data processing tasks in a simple, high-level language.</p><p>Another key feature of Hadoop is its ability to handle data in a distributed manner. By distributing data across multiple nodes in a cluster, Hadoop can process large amounts of data in parallel, making it much faster than traditional single-node systems. Additionally, Hadoop’s built-in fault tolerance ensures that data is not lost in the event of a node failure.</p><p>Hadoop is also highly customizable, with a wide variety of available plug-ins and extensions. This means that it can be used to solve a wide range of big data problems, from simple data processing tasks to more complex machine learning and analytics applications.</p><p>Hadoop is also designed to be easily integrated with other big data technologies, such as Spark, Storm, and Flink. This allows organizations to build big data pipelines that can be easily scaled and adapted to changing business needs.</p><p>In summary, Hadoop is a powerful and versatile big data framework that allows organizations to store, process, and analyze large amounts of data in a distributed environment. Its ability to handle data in a distributed manner, to handle data in a distributed manner, provides fault tolerance and high-performance data processing, and its ability to be easily integrated with other big data technologies make it an attractive option for any organization looking to gain insights from big data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6b40a2aff1f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Wi-Fi: The Convenience of Wireless Connectivity]]></title>
            <link>https://medium.com/@ysunil24359/wi-fi-the-convenience-of-wireless-connectivity-9710c2f0efd9?source=rss-2b1a75c2a89c------2</link>
            <guid isPermaLink="false">https://medium.com/p/9710c2f0efd9</guid>
            <dc:creator><![CDATA[Sunil yadav]]></dc:creator>
            <pubDate>Thu, 19 Jan 2023 16:53:23 GMT</pubDate>
            <atom:updated>2023-01-19T16:53:23.304Z</atom:updated>
            <content:encoded><![CDATA[<p>In today’s fast-paced world, staying connected is more important than ever. With the advent of technology, we have grown accustomed to having access to the internet at all times, whether it’s for work, entertainment, or staying in touch with loved ones. One of the most convenient ways to stay connected is through Wi-Fi, a wireless networking technology that allows us to access the internet without the need for physical cables.</p><p>Wi-Fi technology has come a long way since it was first introduced. It is now found in almost every household, office, and public space. It allows us to connect multiple devices to the internet at the same time, such as smartphones, laptops, tablets, and smart home devices. With Wi-Fi, we can easily share files, stream videos, play games, and work remotely without any interruption.</p><p>One of the biggest benefits of Wi-Fi is its portability. With a wireless connection, we can take our devices with us wherever we go and still have access to the internet. This is especially useful for people who are always on the move, such as business travelers and students. Wi-Fi also eliminates the need for cables and wires, making it much easier to set up and maintain a home or office network.</p><p>However, like any technology, Wi-Fi also has its limitations. One of the most common issues is signal strength, which can be affected by walls, distance, and other obstacles. This can lead to slow internet speeds, dropped connections, and spotty coverage. To combat this issue, many people opt for a wireless range extender or a mesh network system. These devices help to boost the Wi-Fi signal and provide a more stable connection.</p><p>Another issue is security. Wi-Fi networks can be vulnerable to hacking and cyber attacks, which can put your personal information at risk. To protect yourself, it’s important to secure your Wi-Fi network with a strong password and to keep your router’s firmware updated. Additionally, using a virtual private network (VPN) can help to encrypt your data and keep your online activities private.</p><p>In conclusion, Wi-Fi is a convenient and essential technology that we can’t imagine living without. It has changed the way we access the internet and stay connected with the world. While there are some limitations, with the right setup and security measures, we can enjoy a stable and secure wireless connection.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9710c2f0efd9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mongodb Basic things need to know.]]></title>
            <link>https://medium.com/@ysunil24359/mongo-basic-things-need-to-know-f8d15bc85631?source=rss-2b1a75c2a89c------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8d15bc85631</guid>
            <category><![CDATA[mongodb]]></category>
            <dc:creator><![CDATA[Sunil yadav]]></dc:creator>
            <pubDate>Tue, 10 May 2022 06:11:40 GMT</pubDate>
            <atom:updated>2022-05-10T10:26:23.417Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi, I am Sunil yadav. Today i am giving some example how to use a mongodb. Connecting a database, listing, assigning a permission.</p><ol><li><strong>Connecting to mongo</strong></li></ol><p><strong>Command</strong></p><p>#mongo -h &lt;server_ip&gt; — username &lt;username&gt; — password &lt;Password&gt; — authenticationDatabase &lt;Authentication Database&gt;<br>Egs: mongo -h 127.0.0.1 — username sunil — password sunil — authenticationDatabase admin</p><p><strong>2. List Databases</strong></p><p><strong>Command:</strong><br>show dbs</p><p><strong>3. Enter database or Create database</strong></p><p><strong>Command:</strong><br>use &lt;database-Name&gt; (If database is not there it will be created)</p><p>Egs :</p><p>use sunil</p><p><strong>4. List collections (tables) in database</strong></p><p><strong>Command:</strong><br>use &lt;database-Name&gt;<br>show collections or show tables</p><p><strong>5. To confirm data is present in a table (After going inside database with “use” command)</strong></p><p><strong>Command:</strong><br>db.&lt;table-Name&gt;.find().pretty().limit(1)</p><p><strong>Example:</strong><br>db.sunil.find().pretty().limit(1)</p><p><strong>6. To See total count of data inside mongo collection.</strong></p><p><strong>Command:</strong><br>db.&lt;Table-Name&gt;.count()</p><p><strong>Example:</strong><br>db.sunil.count()</p><p><strong>7. To List All the Users</strong></p><p><strong>Command:</strong><br>db.getUsers()</p><p><strong>8. To List particular user</strong></p><p><strong>Command:</strong><br>db.getUser(‘&lt;User-Name&gt;’)</p><p><strong>9. To List particular User with Restrictions</strong></p><p><strong>Command:</strong><br>db.getUser( “&lt;User-Name&gt;”, { showAuthenticationRestrictions: true} )</p><p><strong>10. To Create User</strong></p><p><strong>i. Create User With Inbuilt Access (Accessible from All IPs)</strong></p><p><strong>Command:</strong><br>db.createUser({user: “&lt;User-Name&gt;”, pwd: “&lt;Password&gt;”, roles: [ “&lt;Access-Type&gt;” ]})<br><strong>Example:</strong><br>db.createUser({user: “sunil”, pwd: “c0mp_ap!”, roles: [ “readWriteAnyDatabase” ]})</p><p>i<strong>i. Create User with access on Particular Databases (Accessible from All IPs)</strong></p><p><strong>Command:</strong><br>db.createUser({user: “&lt;User-Name&gt;”, pwd: “&lt;Password&gt;”, roles:[{role: “&lt;AccessType&gt;”, db: “&lt;Database-Name&gt;”}]})</p><p><strong>Example:</strong><br>Single Database<br>===============<br>db.createUser({user: “sunil”, pwd: “sunil”, roles: [ { role: “readWrite”, db: “db_refer_earn” } ]</p><p>Multiple Database<br>=================<br>db.createUser(<br>{<br>user: “sunil”,<br>pwd: “sunil”,<br>roles: [<br>{ role: “read”, db: “reporting” },<br>{ role: “read”, db: “products” },<br>{ role: “read”, db: “sales” },<br>{ role: “readWrite”, db: “accounts” }<br>]<br>}<br>)</p><p><strong>iii. Create User With Access From limtited Servers (Accessible only from servers mentioned in Client Source)</strong></p><p><strong>Command:</strong><br>db.createUser({user: “&lt;User Name&gt;”, pwd: “&lt;Password&gt;”, roles: [ “readWriteAnyDatabase” ], authenticationRestrictions:[{ clientSource: [“&lt;ip1&gt;”,”&lt;ip2&gt;”,”&lt;ip3&gt;”,…..,”&lt;ipn&gt;”]}]})</p><p><strong>Example:</strong><br>db.createUser({user: “sunil”, pwd: “sunil123”, roles: [ “readWriteAnyDatabase” ], authenticationRestrictions:[{ clientSource: [“192.168.0.1”,”192.168.0.2&quot;,”192.168.0.3&quot;,”192.168.0.4&quot;]}]})</p><p><strong>11. Update Users</strong><br><strong>Note: Updating User in Mongo is an update process i.e New data over-writes old data,</strong><br><strong>therefore, Addition and deletion of particular access should be updated with all the access required and not just the data to be updated</strong></p><p><strong>Command:</strong></p><p>db.updateUser( “&lt;User-Name&gt;”,<br>{</p><p>roles : [<br>{ role : “&lt;Access-Type&gt;”, db : “&lt;Databases&gt;” }<br>],<br>authenticationRestrictions: [<br>{ clientSource: [“&lt;ip1&gt;”,”&lt;ip2&gt;”,”&lt;ip3&gt;”,…..,”&lt;ipn&gt;”] }<br>]</p><p>} )</p><p><strong>Example:</strong></p><p>A User Created with Below commnds<br>db.createUser({user: “sunil”, pwd: “c0mp_ap!”, roles: [ “readWriteAnyDatabase” ], authenticationRestrictions:[{ clientSource: [“192.168.0.1”,”192.168.0.2&quot;,”192.168.0.3&quot;,”192.168.0.4&quot;]}]})</p><p>If Now we have to give access to 192.168.0.1 also then Run below Command</p><p>db.updateUser( “sunil”,<br>{</p><p>roles : [<br>{ role : “readAnyDatabase”, db : “admin” }<br>],<br>authenticationRestrictions: [<br>{ clientSource: [“192.168.0.1”,”192.168.0.2&quot;,”192.168.0.3&quot;,”192.168.0.4&quot;,”192.168.0.5&quot;] }<br>]</p><p>} )</p><p><strong>12. Update User Password</strong></p><p><strong>Command:</strong><br>db.changeUserPassword(“&lt;Username&gt;”, “&lt;New-Password&gt;”)</p><p><strong>Example:</strong><br>db.changeUserPassword(“sunil”, “sunil123”)</p><p><strong>13. Delete User</strong></p><p><strong>Command:</strong><br>db.dropUser(“&lt;User-Name&gt;”)</p><p><strong>Example:</strong><br>db.dropUser(“sunil”)</p><p><strong>14. Execute mongo Commands from linux bash terminal</strong></p><p><strong>Command:</strong><br>mongo — host &lt;Server-IP&gt; — username &lt;User-name&gt; — password &lt;Password&gt; — authenticationDatabase &lt;Authentication Database&gt; — eval “printjson(&lt;mongo-command&gt;)”</p><p><strong>Example:</strong><br>mongo — host 127.0.0.1 — username sunil — password sunil@123 — authenticationDatabase admin — eval “printjson(db.serverStatus())”</p><p>mongo — quiet — host 127.0.0.1 — username sunil — password sunil@123 — authenticationDatabase admin — eval “printjson(db.getMongo().getDBNames())”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8d15bc85631" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>