<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: theelvace.eth</title>
    <description>The latest articles on DEV Community by theelvace.eth (@tellaboutcrypt).</description>
    <link>https://dev.to/tellaboutcrypt</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1071025%2F206ff693-15da-47a2-b174-6010f5966172.jpg</url>
      <title>DEV Community: theelvace.eth</title>
      <link>https://dev.to/tellaboutcrypt</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tellaboutcrypt"/>
    <language>en</language>
    <item>
      <title>Revolutionizing Application Deployment and Scalability Using Docker</title>
      <dc:creator>theelvace.eth</dc:creator>
      <pubDate>Tue, 04 Jul 2023 08:04:35 +0000</pubDate>
      <link>https://dev.to/tellaboutcrypt/revolutionizing-application-deployment-and-scalability-using-docker-1mee</link>
      <guid>https://dev.to/tellaboutcrypt/revolutionizing-application-deployment-and-scalability-using-docker-1mee</guid>
      <description>&lt;h2&gt;
  
  
  Table of content:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Introduction &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Understanding Docker: An overview&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Docker Containers&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Docker Images: Building blocks of application deployment&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Streamlining development with Docker Compose&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Orchestrating containers with Docker Swarm&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scaling applications with Docker Swarm mode&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Achieving high availability with Docker services&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Monitoring and managing Docker containers&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Best practices for secure and efficient Docker Deployment&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Conclusion&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;The digital landscape is an ever-evolving one. As a result, there is a need for the efficient deployment and scalability of applications. This is where Docker, a containerization software has proven to be a game-changer. Docker is revolutionizing how software is built, shipped, and run by encapsulating applications and their dependencies into lightweight containers that unleash their flexibility, portability, and scalability.&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.tourl"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Prerequisite:&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;To get the most out of this guide, it is essential that you have a basic understanding of the concepts guiding application development and deployment. Being familiar with topics like software development life cycle, cloud computing, and virtualization will provide you with a solid foundation for understanding the power of Docker in deploying applications in a streamlined way and achieving unparalleled scalability. &lt;/p&gt;

&lt;p&gt;If you are unfamiliar with these technologies, we recommend that you take some time to familiarize yourself with them before proceeding as they will provide you with the prerequisite knowledge you need to get a grasp of the nuances and benefits of Docker's style to application deployment and scalability.&lt;/p&gt;
&lt;h2&gt;
  
  
  Understanding Docker: An overview
&lt;/h2&gt;

&lt;p&gt;Managing an application's dependencies across various cloud environments has proven to be a common problem for DevOps teams. DevOps teams, as part of their regular tasks, make sure to keep the application stable and operational while development teams have their strength in releasing new updates and product features. Now, while there is a need to improve applications so they can serve us better, regular "new update" releases can compromise the stability of the application. Even more when deployed codes introduce bugs that are dependent on the application's environment. &lt;/p&gt;

&lt;p&gt;This is a big issue and in an effort to avoid this inefficiency, companies are increasingly adopting the model of a containerized framework that allows for the designing of a stable framework. A framework that does not have issues like security vulnerabilities, operational failures, and complexities added to it. &lt;/p&gt;

&lt;p&gt;Containerization in simple terms is the process of building and packaging an application's code with all of the dependencies, configuration files, and libraries that the application needs, into an isolated environment (sometimes called a Sandbox), where they can operate efficiently as an independently executable unit. &lt;/p&gt;

&lt;p&gt;Containers are popular for their usability issues but they have gained an increased level of prominence in recent times since Docker entered the fray. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Docker&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Docker is a free-to-download open-source containerization platform that allows developers to build, ship, run, and package applications with ease using containers. Docker technology is packaged as containers (standardized units), with elements like libraries, system tools, runtime, etc that are needed for the software to function properly. The operations provided by the platform can be carried out using the Command Line Interface (CLI) it comes with. &lt;/p&gt;

&lt;p&gt;If you are familiar with software environments, you could say Virtual Machines (VMs) are another way with which you can create isolated environments but Docker, unlike VMs, offers perks like faster execution of applications, interoperability, and build and test efficiency. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installing Docker&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can Install Docker on a Linux-based system with the following steps: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;to update the package index&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install required packages to allow apt to use a repository over HTTPS with:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install apt-transport-https ca-certificates curl software-properties-common
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Add the official Docker GPG key using:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Add Docker repository to APT sources with:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list &amp;gt; /dev/null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Update the package index again:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Now install Docker Engine:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install docker-ce docker-ce-cli containerd.io
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Verify that Docker is installed and running with:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl status docker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;If the above command's output shows that Docker is active and running, then you have successfully installed Docker on your system.&lt;/p&gt;

&lt;p&gt;Note that these commands and instructions are specific to Ubuntu-based systems. Other Linux distributions may have varying commands and packages. Refer to the official Docker documentation for instructions on how to install Docker for the specific Linux distribution you use. &lt;/p&gt;
&lt;h2&gt;
  
  
  Docker Containers
&lt;/h2&gt;

&lt;p&gt;Containers are live instances of a Docker image on which the application runs. You can create, start, stop, or delete a container by using the Docker CLI or API. A container by default is isolated from other containers and its host machine, but you can control how isolated a container's network and other subsystems are from other containers or from the host machine. &lt;/p&gt;

&lt;p&gt;A container can also be connected to one or more networks, storage attached to it, and even create a new image based on the container's current state. &lt;/p&gt;

&lt;p&gt;You can use Docker Compose, an open-source tool to define and deploy multi-container Docker applications. You can use a YAML file to configure the application's services. Docker Compose works in all environments and it has commands that help you manage the entire lifecycle of your application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installing and Using Docker Compose&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Follow the steps below to install and use Docker Compose:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install Docker Compose:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Add executable permissions to the binary:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo chmod +x /usr/local/bin/docker-compose
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Check the version to verify the installation:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker-compose --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Next, create a Docker Compose file in your project directory &lt;code&gt;docker-compose.yml&lt;/code&gt;. The file defines the services, networks, and volumes for your application. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Define your services using the appropriate syntax inside the Docker Compose file. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example of a simple Docker Compose file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: '3'
   services:
     web:
       build: .
       ports:
         - '8000:8000'
     db:
       image: postgres
       environment:
         POSTGRES_PASSWORD: example
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The example above defines two services: &lt;code&gt;web&lt;/code&gt; and &lt;code&gt;db&lt;/code&gt;. The &lt;code&gt;web&lt;/code&gt; service builds an image from the current directory and maps port 8000 on the host to port 8000 in the container. The &lt;code&gt;db&lt;/code&gt; service uses the &lt;code&gt;postgres&lt;/code&gt; image and sets the &lt;code&gt;POSTGRES_PASSWORD&lt;/code&gt; environment variable.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Start the services defined in the Docker Compose file from your project directory:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker-compose up
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command starts the containers and displays the logs in the terminal.&lt;/p&gt;

&lt;p&gt;You can use the &lt;code&gt;-d&lt;/code&gt; flag to run the containers in the background:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker-compose up -d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;You can stop and remove the containers using:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker-compose down
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This stops and removes the containers defined in the Docker Compose file.&lt;/p&gt;

&lt;p&gt;Note: To do all of these, it is assumed that you already have Docker installed. &lt;/p&gt;

&lt;h2&gt;
  
  
  Docker Images: Building blocks of application deployment
&lt;/h2&gt;

&lt;p&gt;Docker Images help you create a Docker container. Default images show all the top-level images, their repository and tags, and their sizes. Images essentially define the application's dependencies and the processes that run when the application launches. &lt;/p&gt;

&lt;p&gt;Docker Images has intermediate layers that are not shown by default and they increase reusability, decrease disk usage, and speed up Docker build as each step is cached. Images are building blocks of application deployment and you can get them from DockerHub or you can create your own images by adding specific instructions to a file called Dockerfile.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting up Docker Image&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After creating the Docker file, open it in a text editor and define the instructions to build your Docker image. See an example of a Dockerfile for a basic Python application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Use a base image with Python pre-installed
   FROM python:3.9

   # Set the working directory in the container
   WORKDIR /app

   # Copy the requirements file and install dependencies
   COPY requirements.txt .
   RUN pip install --no-cache-dir -r requirements.txt

   # Copy the application code into the container
   COPY . .

   # Specify the command to run when the container starts
   CMD ["python", "app.py"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The example above has the &lt;code&gt;python:3.9&lt;/code&gt; base image pre-installed. The working directory in the container is set to &lt;code&gt;/app&lt;/code&gt;, and it copies the &lt;code&gt;requirements.txt&lt;/code&gt; file, installs dependencies, and then copies the rest of the application code. In the last line, it specifies the command to run when the container starts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can customize the Dockerfile according to the requirements of your application. For advanced options and instructions, refer to the Docker documentation. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Next, save the Dockerfile in your project directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Build the Docker Image with the &lt;code&gt;docker build&lt;/code&gt; command by opening a terminal or command prompt and navigating to your project directory:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker build -t your-image-name .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;your-image-name&lt;/code&gt; with your desired Docker Image name. &lt;/p&gt;

&lt;p&gt;The build context is defined as the current directory by the &lt;code&gt;.&lt;/code&gt; at the end.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Docker will then execute the instructions in the Dockerfile and build the image. This process may take some time depending on the size of the project and the instructions defined in the Dockerfile.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can verify that the image was created by running:&lt;br&gt;
&lt;code&gt;docker images&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This command will list all the Docker images on your system, and you should see your newly created image listed.&lt;/p&gt;

&lt;p&gt;Your Docker image is now set up and ready to use. &lt;/p&gt;

&lt;p&gt;Note: You can run containers based on this image by using the docker run command and specifying the image name.&lt;/p&gt;

&lt;h2&gt;
  
  
  Streamlining development with Docker Compose
&lt;/h2&gt;

&lt;p&gt;With a single YAML file, using Docker Compose, a developer can describe their application's services, volumes, and networks in a YAML file. This makes it easy for the configuration and reproduction of development environments across different machines. With the use of Docker Compose, it is easier for the developer to spin up containers that are interconnected, testing, debugging, and iterating their applications with ease. &lt;/p&gt;

&lt;p&gt;The process of managing dependencies is simplified by Docker Compose, and this ensures that the necessary services are available and properly connected. This tool streamlines development by providing an easy and efficient way to define, manage, and orchestrate multi-container applications. This approach accelerates development cycles. &lt;/p&gt;

&lt;h2&gt;
  
  
  Orchestrating containers with Docker Swarm
&lt;/h2&gt;

&lt;p&gt;You can create and deploy a cluster of Docker nodes with the aid of Docker Swarm, an orchestration tool that works with Docker applications. With this tool, containers are launched with the use of services. Services are containers of the same image that enables the scaling of applications. To deploy a service in Docker Swarm, the user must have at least one node deployed. &lt;/p&gt;

&lt;p&gt;A node in a Docker Swarm is a Docker daemon and they (Docker daemons) interact through the use of the Docker API. &lt;/p&gt;

&lt;h2&gt;
  
  
  Scaling applications with Docker Swarm mode
&lt;/h2&gt;

&lt;p&gt;Scaling applications using Docker Swarm and achieving a high level of availability and scalability involves proper deployment and management of a cluster of Docker nodes. Docker nodes are essentially a swarm created in swarm mode. These nodes in a swarm act as a single entity. &lt;/p&gt;

&lt;p&gt;As a developer, you need to define a desired number of replicas in the Docker Compose file or use the Docker command line to scale an application. As you scale up, additional replicas are created and spread across the nodes. Scaling down removes the excess replicas. If there is an increase in traffic, the swarm mode load balances the requests among the service replicas automatically. This way, applications adjust their capacity to efficiently meet demand and maintain high-performance standards. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting up Docker Swarm&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;You can follow these steps to set up Docker Swarm:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Initialize Docker Swarm on the manager node (your machine) with:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker swarm init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If successful, the output will include a command to join worker nodes to the swarm. You need to copy this command because you will need it to join worker nodes later.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To add worker nodes to the swarm, run the command that you copied from the previous step on each worker node:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker swarm join --token &amp;lt;TOKEN&amp;gt; &amp;lt;MANAGER_IP&amp;gt;:&amp;lt;MANAGER_PORT&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should replace &lt;code&gt;&amp;lt;TOKEN&amp;gt;&lt;/code&gt; with the token value from the command output and &lt;code&gt;&amp;lt;MANAGER_IP&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;MANAGER_PORT&amp;gt;&lt;/code&gt; with the IP address and port of the manager node.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Next, you can check the status of the swarm and view the nodes:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;docker node ls&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This lists all the nodes in the swarm, including manager, and worker nodes included.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Create a Docker Compose file (e.g., &lt;strong&gt;docker-compose.yml&lt;/strong&gt;) to deploy a service on the swarm that defines your desired services, networks, and volumes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Deploy the stack defined in the Docker Compose file using the following command:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker stack deploy -c docker-compose.yml &amp;lt;STACK_NAME&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should replace &lt;code&gt;&amp;lt;STACK_NAME&amp;gt;&lt;/code&gt; with a name of your choice for the stack.&lt;/p&gt;

&lt;p&gt;After these, Docker Swarm will create the necessary services, networks, and volumes that are specified in the Docker Compose file. Docker Swarm will also distribute them across the available nodes in the swarm.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To view the running services in the swarm, use the command:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;docker service ls&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;For advanced usage and added features of Docker Swarm, refer to the Docker documentation. &lt;/p&gt;

&lt;h2&gt;
  
  
  Achieving high availability with Docker services
&lt;/h2&gt;

&lt;p&gt;Implementing strategies to ensure that an application that runs in a Docker container is still accessible even with disruptions is important in achieving a high level of availability with Docker services. Typically, this is achieved by deploying multiple instances of the application across a cluster of Docker nodes, and Kubernetes or Docker Swarm can then be used to distribute containers across the cluster. &lt;/p&gt;

&lt;p&gt;To ensure the even distribution of traffic among the containers, load balancing techniques are employed. Doing this prevents any instance from being overwhelmed. Auto-recovery mechanisms and regular health checks can be used to detect and recover container failures. Doing these and leveraging scalability, ensures that high availability is achieved and that Docker services are continuously available thereby reducing downtime for applications. &lt;/p&gt;

&lt;h2&gt;
  
  
  Monitoring and managing Docker containers
&lt;/h2&gt;

&lt;p&gt;Docker Containers provide developers with so many benefits. Benefits like the ability to test and deploy an application with ease, cost-effectiveness, and mobility are some of the perks of containerization. It is important to manage Docker containers because many services depend on them. &lt;/p&gt;

&lt;p&gt;Command line interfaces are more common than Graphical User Interfaces (GUIs), which play perfectly in managing Docker containers. A GUI generally has changes done to it regularly and the user experience can prove difficult because options and how they work are changed. In contrast, a CLI doesn't get updated a lot and this makes it easy to get used to. &lt;/p&gt;

&lt;p&gt;There's also the issue of GUI having bug problems which affect the operation of managing Docker. The CLI is largely bug-free and stable. All these make managing Docker containers using CLI tools convenient and safe. These are some commands that you can use to monitor Docker containers in real time:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;docker attach: Helps you attach to a running container and view outputs&lt;/li&gt;
&lt;li&gt;docker events: Use this to view real-time events from the Docker daemon. Events like when a container is created or destroyed&lt;/li&gt;
&lt;li&gt;docker top: This helps you view the running processes of a container&lt;/li&gt;
&lt;li&gt;docker logs: To view the logs of a running container&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Examples of some Docker CLI monitoring tools you can try are &lt;a href="https://lirantal.github.io/dockly/" rel="noopener noreferrer"&gt;Dockly&lt;/a&gt;, &lt;a href="https://moncho.github.io/dry/" rel="noopener noreferrer"&gt;Dry&lt;/a&gt;, &lt;a href="https://getpoco.io/" rel="noopener noreferrer"&gt;Poco&lt;/a&gt;, &lt;a href="https://github.com/wagoodman/dive" rel="noopener noreferrer"&gt;Dive&lt;/a&gt;, etc. &lt;/p&gt;

&lt;h2&gt;
  
  
  Best practices for secure and efficient Docker Deployment
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;An efficient Docker deployment involves several best practices that ensure the protection of containerized applications. Below are some of these practices:&lt;/li&gt;
&lt;li&gt;Use base images from trusted and reliable sources and keep them updated with regular security patches &lt;/li&gt;
&lt;li&gt;Employ network segmentation and container network security measures to help protect the application against network-induced attacks. &lt;/li&gt;
&lt;li&gt;Implement strong access controls like user namespaces, and restrict the container's capabilities to enhance isolation and reduce potential vulnerabilities.&lt;/li&gt;
&lt;li&gt;Use container orchestration platforms like Kubernetes to enable efficient management of containerized applications, load balancing, and automatic scaling.&lt;/li&gt;
&lt;li&gt;Use security tools to scan containers and their dependencies regularly for known vulnerabilities. &lt;/li&gt;
&lt;li&gt;Monitor and log container activities and implement centralized logging and Security Information and Event Management (SIEM) solutions. This allows for effective security incident detection and response.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Docker has become a game-changer in application deployment and scalability. This technology leverages lightweight containers and flexible orchestration tools to empower businesses to streamline their development processes and scale applications to meet the ever-growing demands of the digital landscape. As Docker continues to evolve, embracing it is not just a choice, it is an essential step toward reaching a new level of efficient application deployment and scalability.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>containers</category>
      <category>cloudcomputing</category>
    </item>
    <item>
      <title>What You Need to Know About Run Levels in Linux</title>
      <dc:creator>theelvace.eth</dc:creator>
      <pubDate>Mon, 24 Apr 2023 20:59:41 +0000</pubDate>
      <link>https://dev.to/tellaboutcrypt/what-you-need-to-know-about-run-levels-in-linux-10fd</link>
      <guid>https://dev.to/tellaboutcrypt/what-you-need-to-know-about-run-levels-in-linux-10fd</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4o6593tmuiflaptgfsu2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4o6593tmuiflaptgfsu2.png" alt=" " width="800" height="565"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Graphical user interface (GUI) and command-line interface (CLI). Oh, snap! I realize I’ve just blurted out those terms without context, let me add context. The GUI and CLI are the two options a Linux operating system (OS) boots to when turned on. When the system finishes booting up, the applications it executes are determined by Run levels. Run levels also determine the state of the system after booting.&lt;/p&gt;

&lt;p&gt;In essence, run levels in Linux can be considered as the different modes the OS runs in. These modes/run levels have their list of processes or the services they provide and these are either turned on or off. As you continue to work with your computer, and depending on the kind of services the OS is accessing, the run level may change.&lt;/p&gt;

&lt;p&gt;For instance, if you are running your Linux machine with a GUI, the run level for this is different from when you are running the CLI on your system. The reason for this is simple. The GUI will need access to services that the command line does not need.&lt;br&gt;
_&lt;/p&gt;

&lt;p&gt;In this article, we will talk about run levels in Linux, the different types of run levels, changing run levels in a system, list services that are enabled at a run level, and some Init scripts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Table of Contents&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What is Run Level?&lt;/li&gt;
&lt;li&gt;Linux System Boot Process&lt;/li&gt;
&lt;li&gt;Types of Run Levels&lt;/li&gt;
&lt;li&gt;Changing Run Levels&lt;/li&gt;
&lt;li&gt;Services That Are Enabled at a Run Level&lt;/li&gt;
&lt;li&gt;init scripts&lt;/li&gt;
&lt;li&gt;Examples of Run Level Commands&lt;/li&gt;
&lt;li&gt;Security Issues That Affect Run Levels in Linux&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;li&gt;Resources&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  What is Run Level?
&lt;/h2&gt;

&lt;p&gt;A run level is an operating state of init on a Unix or Linux-based operating system. It determines what system services are operating and which programs can be executed after the OS boots up. In essence, the state of the machine after boot is defined by the run level.&lt;/p&gt;

&lt;p&gt;System administrators use run levels to define system-related issues like which subsystems are working if the network is operational if a command/file/program is running etc. The run level command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/sbin/runlevel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;can be used to find out the current or previous run level of the OS. These run levels are usually identified by numbers (0–6). Each of these levels controls a system configuration different from the other levels and they allow access to the combination of different processes.&lt;/p&gt;

&lt;p&gt;To view the current run level for a system, you can use the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ runlevel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flryxve49g5araceocwu8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flryxve49g5araceocwu8.png" alt=" " width="800" height="61"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The command below can also be used:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ who -r
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx5gl28e5zkcflzjkpppn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx5gl28e5zkcflzjkpppn.png" alt=" " width="800" height="61"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Linux System Boot Process
&lt;/h2&gt;

&lt;p&gt;When a Linux system boots up, the first thing that happens is that the init process starts. To execute the start scripts that are appropriate for the default run level, the init first determines the system’s default run level. It is this process that is responsible for the initialization of the hardware, bringing up the network, and starting the GUI.&lt;/p&gt;

&lt;h2&gt;
  
  
  Types of Run Levels
&lt;/h2&gt;

&lt;p&gt;There are seven run levels in Linux and they are numbered from zero to six. According to the operating system or Linux distribution, these run levels may be used differently. As a result, it is not very easy to come up with a clearly defined list of the run levels and what they do. You should check the specific distribution that you use, and how the run levels work on it.&lt;/p&gt;

&lt;p&gt;However, the standard LINUX kernel supports the seven different run levels listed below:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Run Level 0 — In this run level, the system can safely be shut down&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run Level 1 — This is a single-user mode and it is used for maintenance or administrative activities. This mode can also be referred to as run level S(S represents single-user).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run Level 2 — This is a multi-user mode and it has no Network File System (NFS).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run Level 3 — This is a multi-user mode under the command line interface. It is the run level you use if your system doesn’t boot into a graphical user interface.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run Level 4 — This run level is user-definable. What this means is that the user can customize the level to fit their purposes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run Level 5 — This run level works the same as run level 3, but it also starts a display manager. This is the standard run level for most Linux-based systems that boot up into a GUI.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run Level 6 — This run level reboots the system.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is important to note from the above listed that each run level has a different purpose.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Run levels 0,1 and 6 are the same.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Depending on the Linux distribution being used, Run levels 2–5 are different&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When the system is booted, only one level executes&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Finally, run levels are executed in a sequence. This means that either levels 2 or 3 or 4 are executed, and not 2 then 3 then 4.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Changing Run Levels
&lt;/h2&gt;

&lt;p&gt;Using the init or telinit command, we can alter the run level. The telinit command can be used to invoke the init program, which is used to change the run level.&lt;/p&gt;

&lt;p&gt;For instance, to reboot a system, you can use the:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ init 6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ telinit 6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To change the run level, we first have to get the current run level by using the systemctl command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ systemctl get-default
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4usqk1xvio9gkg7mbzi9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4usqk1xvio9gkg7mbzi9.png" alt=" " width="800" height="61"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Graphical.target represents run level 5. Other targets include&lt;/p&gt;

&lt;p&gt;poweroff.target (run level 0), rescue.target (run level 1), multi-user.target (run level 3), and *reboot.target (run level 6).&lt;/p&gt;

&lt;p&gt;Now we can change the run level from the current level it is at to run level 3. This run level supports multi-user and on it, we can operate in the CLI with networking enabled.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo systemctl isolate multi-user.target
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fedhbzkc3ndcqe1iej817.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fedhbzkc3ndcqe1iej817.png" alt=" " width="800" height="41"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We are directed to a login screen on a command-line interface after entering the password.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F017o69j0mdum7167rohe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F017o69j0mdum7167rohe.png" alt=" " width="800" height="138"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can confirm the run level by using the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ who -r
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fij4gtr9q60dv0y25252i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fij4gtr9q60dv0y25252i.png" alt=" " width="800" height="61"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To go back to the graphical interface, we can use the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo systemctl isolate graphical.target
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq0oudih8i0xppc2gn1sy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq0oudih8i0xppc2gn1sy.png" alt=" " width="800" height="44"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: It is important to note that the changing of run levels is a task for the super user. This is why for the successful execution of the changing run levels process above, it is important to be logged in as the super user. Or you can use the sudo command.&lt;/p&gt;

&lt;h2&gt;
  
  
  Services That Are Enabled at a Run Level
&lt;/h2&gt;

&lt;p&gt;Until recently, to list the services that would be enabled at different run levels, “chkconfig — — list” was the command used. However, if your OS is up to date, using that command may give you an error or push you over to systemd.&lt;/p&gt;

&lt;p&gt;Now if we want to see what services will be enabled when we boot our system into the run level 5 (graphical mode), we can use this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ systemctl list-dependencies graphical.target
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F14ioemn16yhjlxmh0xpi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F14ioemn16yhjlxmh0xpi.png" alt=" " width="800" height="796"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can replace “graphical.target” with the name of a target service we want to see to see the services that run by default on other run levels.&lt;/p&gt;

&lt;h2&gt;
  
  
  init scripts
&lt;/h2&gt;

&lt;p&gt;init is the program that is responsible for launching other processes during the boot-up of a system. Linux system’s default state is configured in scripts of config files and these are located in the /etc/init.d/ directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ls /etc/init.d/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5pqablzl8vgdtwd3t44n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5pqablzl8vgdtwd3t44n.png" alt=" " width="800" height="144"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Run levels are found in the /etc/ directory, and each run level has its directory here:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ls /etc/ | grep rc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2x704twr19qbg6dnc9l6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2x704twr19qbg6dnc9l6.png" alt=" " width="800" height="237"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In each subdirectory, configuration files for a run level are kept. For example, to list all the configuration scripts under run level 0, we can use&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ls /etc/rc0.d/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpnni3a008j65ibtlwgdu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpnni3a008j65ibtlwgdu.png" alt=" " width="800" height="118"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Examples of Run Level Commands
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;To see the current run level use the:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ runlevel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;To suppress the output:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ runlevel -q
$ runlevel - quiet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;To run in verbose mode:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ runlevel -v
$ runlevel - verbose
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;To get the version info:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ runlevel - version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;To get help:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ runlevel - help
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;To check the runlevel manual:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ man runlevel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Security Issues That Affect Run Levels in Linux
&lt;/h2&gt;

&lt;p&gt;The main point of run levels in Linux is to give the system administrator granular control over the system. Such control improves security because the administrator is then sure that no other services are running without permission. A very important practice when using run levels is to only use the run level you need. This means that there is no point in starting the graphical interface (run level 5) when you only want to use the terminal. Doing this — having different run levels on — introduces multiple services, some of which you may forget to secure because they run in the background.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;It is important to understand run levels and how they work. Knowledge of this is useful especially when accessing the system, fixing a damaged config file, or in the case of a forgotten password. In any of these situations, we will boot into a single-user mode. And as mentioned earlier in the article, run level configurations vary across the different Linux distributions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;p&gt;You may find the following resources helpful:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.techtarget.com/searchdatacenter/definition/runlevel" rel="noopener noreferrer"&gt;Run Levels&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.freecodecamp.org/news/the-linux-booting-process-6-steps-described-in-detail/" rel="noopener noreferrer"&gt;Linux System Boot Process&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.tecmint.com/change-runlevels-targets-in-systemd/" rel="noopener noreferrer"&gt;Changing Run Levels&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://security.stackexchange.com/questions/150564/linux-runlevel-configuration-security" rel="noopener noreferrer"&gt;Run Levels Security Configuration&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devops</category>
      <category>linux</category>
      <category>runlevels</category>
    </item>
    <item>
      <title>The Basics of Package Management in Linux</title>
      <dc:creator>theelvace.eth</dc:creator>
      <pubDate>Mon, 24 Apr 2023 19:48:06 +0000</pubDate>
      <link>https://dev.to/tellaboutcrypt/the-basics-of-package-management-in-linux-16aa</link>
      <guid>https://dev.to/tellaboutcrypt/the-basics-of-package-management-in-linux-16aa</guid>
      <description>&lt;p&gt;In our world today, technologies move at a fast pace. Constant development and deployment provide the end-users with a plethora of options. As a result of these regular launchings, the possibilities of errors occurring are more pronounced. Errors when left unchecked lead to bad code which in turn affects the product’s quality.&lt;/p&gt;

&lt;p&gt;This is why it is important to carry out necessary updates and automate real-time checks on the software. Most importantly, these should be done without affecting the performance of the application. DevOps and Cloud Infrastructure Engineers have these unenviable tasks, and where they are not present, the companies use DevOps practices to ensure the release of quality software, while building quality collaboration between their Developers and Operations teams.&lt;/p&gt;

&lt;p&gt;To be a well-grounded DevOps Engineer or implement DevOps practices efficiently, it is important to have solid knowledge and experience in the basics. One of these basics is Linux and the management of packages in it.&lt;/p&gt;

&lt;p&gt;This article will show you what package management in Linux is, how you can get started in it, the different package management systems and their benefits, and some core concepts and commands to help you install and work around these package managers.&lt;/p&gt;




&lt;p&gt;The most common tasks a sysadmin has to take care of are installing, patching, and removing software packages on Linux machines. This is because, on Linux, the software is generally built as packages which are then distributed through repositories (repos) before entering the management phase on the end-user’s system through package managers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Package Management
&lt;/h2&gt;

&lt;p&gt;The method of using specific repositories to install, update, remove, and track software updates in the Linux system is known as Package Management. Every Linux system contains thousands of packages, of which many are required dependencies for other packages.&lt;/p&gt;

&lt;p&gt;A package manager is a software in a Linux system that provides a consistent and automated process of installing, upgrading, configuring, and removing packages from the operating system.&lt;/p&gt;

&lt;p&gt;Operating systems (OS) depend on software applications to carry out tasks that solve problems for the user. When software and operating systems were still early and weren’t that popular, applications were developed and tested for bugs before they were released. This was done to provide a good user experience. Not any longer. Now, applications are released to apply bug fixes in newer versions. These newer versions are accessed with the use of updaters or by the user obtaining an upgraded release of the software.&lt;/p&gt;

&lt;p&gt;Linux however has adopted a timely software management practice where they create packaging formats, unique tools for installation, and software packages. To achieve these, Linux distributions (distros) use different package management tools. In the rest of this article, we will talk about package installation tools like Tarball and package management tools like DEB and RPM, and YUM.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tarball
&lt;/h2&gt;

&lt;p&gt;In adding software to early Linux systems, the user was required to download the source code of the software and compile it in binary files, before adding them to the system. The software is made available by users in a compiled form that is known as the tarball (Tar). A tarball typically contains multiple files ranging from configuration files to documentation, to executables, and libraries. All of these files are compressed into a single file for ease of storage and distribution.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5nys3l7fwgsvbdvclo2s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5nys3l7fwgsvbdvclo2s.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Short for “tape archive,” Tar is especially useful for testing and development of software and it supports most Linux distributions like Ubuntu, CentOS, and Amazon Linux 2. While the creation of tarball may seem easy, the process of installing it isn’t as easy. For example, because tarball package installation spreads the files connected to the software being installed across the system, it’s not an easy task locating the package documentation and configuration files even if the user knows the commands.&lt;/p&gt;

&lt;p&gt;This makes it difficult to locate files to uninstall software. Tracking bugs and getting newer versions of software also becomes difficult because of the absence of Metadata in tarballs which confuses the version details after installation. To solve these problems, software packaging in Linux distributions grew into two formats:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Debian-based Linux distributions&lt;/li&gt;
&lt;li&gt;RPM Packaging&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Debian-based Packaging (DEB)
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2oi0n0mae45mkhpl63f3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2oi0n0mae45mkhpl63f3.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the software package used by Debian Linux distributions. All relevant files with metadata in a .ar archive format are included in the .deb files. The metadata here contains relevant details of the software like the version, licenses, description, dependencies, etc. Debian distributions are popular for offering both graphical interfaces and terminal-based tools for managing .deb files.&lt;/p&gt;

&lt;p&gt;Some of these tools include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;dpkg&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This allows the user to set up, remove, manipulate, and upgrade software easily. The dpkg downloads DEB package content to the system and sends notifications about the essential dependencies. You can install a .deb file using dpkg with the command below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo dpkg -i &amp;lt;package name&amp;gt;.deb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Apt&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is an Ubuntu advanced package manager that uses an apt-get command to search and manage package installation. You can install a package from the repository using the apt-get command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get install -s &amp;lt;package name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Aptitude&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is a package management tool that provides a text-based interface to run in the terminal. Because Aptitude doesn’t come pre-installed in all Linux distros, you will have to install it with the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get install aptitude
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once Aptitude is installed, to install a package, issue the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aptitude install &amp;lt;package name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Ubuntu Software Centre&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is an intuitive graphical user interface that users who are new to Linux can use in searching and installing packages.&lt;/p&gt;

&lt;h2&gt;
  
  
  RPM Packaging
&lt;/h2&gt;

&lt;p&gt;Originally called Red Hat Package Manager, the RPM Package Manager is an open-source program for installing, uninstalling, and managing software packages in Linux. It is used in CentOS, Red Hat, Fedora, OpenSUSE, OpenMandriva, and RHEL-based Linux distributions. The RPM Package Manager combines binaries and available files that are required via upstream software providers to create an RPM package. With the aid of signatures, users can verify the validity of packages before they are added to a repository. With this done, users can access the verified packages from the repositories that are placed inside the CDs or directories through FTP/NFS servers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7juhej8idsok16z6pf6u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7juhej8idsok16z6pf6u.png" alt=" " width="300" height="257"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to use RPM
&lt;/h2&gt;

&lt;p&gt;To use RPM commands you first need to gain sudo permission and you’ll probably need to have a package you want to install already.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Install RPM Package&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To install a file using RPM, you can execute the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ rpm -i [package_file_name].rpm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Uninstall RPM Package&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To uninstall a package, you can use the package name instead of the full RPM file name. You can also add more package names. This will help you remove multiple packages in one command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ rpm -e [package_name] [another package_name…]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Upgrade&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ rpm -u [package_file_name].rpm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Verify RPM Package&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use the command below to verify an installed RPM package.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ rpm -Vp sqlbuddy-1.3.3–1.noarch.rpm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Query RPM Package Information (Before Installing)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To see a package’s information before you install it, use&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ rpm -qip [package_name]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Query Package Information (After Installing)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To see the package information after installing, you can use&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ rpm -qi [package_name]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;List Documentation of Installed RPM Package&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To check the available documentation of an installed RPM package use the command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ rpm -qdf /usr/bin/[package_name]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There have been some problems with the RPM package. A major one is that it fails in the absence of dependencies. While the DEB-based software packaging could resolve this dependency problem, following the increasing popularity of RPM packages, YUM facilities are resolving the issue better.&lt;/p&gt;

&lt;h2&gt;
  
  
  Yellowdog Updater Modified (YUM)
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F067vm57xva7xzkn2iz05.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F067vm57xva7xzkn2iz05.png" alt=" " width="325" height="155"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;YUM serves as the primary package management tool for installing, updating, and managing software packages in Red Hat Enterprise Linux. YUM is used to manage packages in CentOS/RHEL 7, Fedora 21, and earlier versions of these distributions. It carries out dependency resolution when installing, updating, and removing software packages.&lt;/p&gt;

&lt;p&gt;YUM was introduced initially to manage the dependencies of RPM packages. It considers each RPM package as part of a large software repository. YUM provides an interface that is easy to use on top of the functions that are available in the RPM Package Manager. YUM’s main configuration file is at /etc/yum.conf, and the repos are at /etc/yum.repos.d.&lt;/p&gt;

&lt;p&gt;There are a lot of commands and options available to use with YUM. Below are a few of them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;yum install&lt;/strong&gt; — To install specified packages&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;update&lt;/strong&gt; — To update each package&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;remove&lt;/strong&gt; — This removes specified packages&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;search&lt;/strong&gt; — To search for keywords&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;repolist&lt;/strong&gt; — This lists repositories&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this article, you’ve learned what package management is and some package managers there are. Package management is a constant for every system and a task that needs to be carried out. Managers like RPM and YUM provide seamless ways of installing, upgrading, removing, and tracking software packages on RHEL systems.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;p&gt;You may find the following resources helpful:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.linux.com/what-is-linux/" rel="noopener noreferrer"&gt;What is Linux?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://linuxhint.com/package-management-linux-introduction/" rel="noopener noreferrer"&gt;Package Management in Linux&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.networkworld.com/article/3328840/working-with-tarballs-on-linux.amp.html" rel="noopener noreferrer"&gt;Tarball in Linux&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://wiki.debian.org/deb" rel="noopener noreferrer"&gt;Debian&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://rpm-packaging-guide.github.io/" rel="noopener noreferrer"&gt;RPM Guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.digitalocean.com/community/tutorials/what-is-yum" rel="noopener noreferrer"&gt;YUM&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
  </channel>
</rss>
