<?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: Vultr</title>
    <description>The latest articles on DEV Community by Vultr (vultr).</description>
    <link>https://dev.to/vultr</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.us-east-2.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F13147%2Fb80ac1b8-cd21-44b9-9bf8-38224e413737.png</url>
      <title>DEV Community: Vultr</title>
      <link>https://dev.to/vultr</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vultr"/>
    <language>en</language>
    <item>
      <title>Committing Changes to an Image in Docker</title>
      <dc:creator>Sanskriti Harmukh</dc:creator>
      <pubDate>Fri, 20 Nov 2026 01:27:19 +0000</pubDate>
      <link>https://dev.to/vultr/committing-changes-to-an-image-in-docker-4m39</link>
      <guid>https://dev.to/vultr/committing-changes-to-an-image-in-docker-4m39</guid>
      <description>&lt;p&gt;Docker is an open-source platform for deploying, scaling, and managing applications in lightweight, isolated containers. Changes made to a running container — such as installing packages or modifying files — are temporary and lost when the container is removed or recreated, unless you commit them or use volumes to persist data. This guide explains how to commit changes from a running or stopped container into a new Docker image using &lt;code&gt;docker container commit&lt;/code&gt;, including the available flags and when to use this approach instead of a Dockerfile. By the end, you'll have a custom Docker image built from a modified container, ready to reuse, share, or push to a registry.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;docker container commit&lt;/code&gt; vs &lt;code&gt;docker image push&lt;/code&gt;
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;&lt;code&gt;docker container commit&lt;/code&gt;&lt;/th&gt;
&lt;th&gt;&lt;code&gt;docker image push&lt;/code&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Purpose&lt;/td&gt;
&lt;td&gt;Creates a new image from a running or stopped container&lt;/td&gt;
&lt;td&gt;Uploads a local image to a remote container registry&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Usage Context&lt;/td&gt;
&lt;td&gt;Used after modifying a container to save its state&lt;/td&gt;
&lt;td&gt;Used to share images across systems or with other users&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Source&lt;/td&gt;
&lt;td&gt;Running or exited container&lt;/td&gt;
&lt;td&gt;Existing Docker image&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Target&lt;/td&gt;
&lt;td&gt;Local Docker image store&lt;/td&gt;
&lt;td&gt;Remote registry (for example, Docker Hub or another container registry)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Persistence&lt;/td&gt;
&lt;td&gt;Saves container changes locally as a new image&lt;/td&gt;
&lt;td&gt;Distributes images for use on other systems&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Typical Workflow&lt;/td&gt;
&lt;td&gt;Development, debugging, or snapshotting container state&lt;/td&gt;
&lt;td&gt;Deployment and versioning across environments&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Quick Reference
&lt;/h2&gt;

&lt;p&gt;Use the following commands as a quick reference to commit changes from a running container, create a new image, and optionally push it to a container registry:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ docker container ls
$ docker container commit -m &lt;span class="s2"&gt;"Save config"&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;container-id&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;image-name&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;:&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;tag&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
$ docker image ls
$ docker image tag &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;image-name&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;:&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;tag&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;username&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;image-name&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;:&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;tag&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
$ docker image push &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;your-registry&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;image-name&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;:&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;tag&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Command Usage
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;docker container commit&lt;/code&gt; command creates a new image from the current state of a running or exited container. Use it after making changes to a container, such as installing packages or configuring software, to save those modifications as a reusable Docker image.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ docker container commit &lt;span class="o"&gt;[&lt;/span&gt;OPTIONS&lt;span class="o"&gt;]&lt;/span&gt; CONTAINER &lt;span class="o"&gt;[&lt;/span&gt;REPOSITORY&lt;span class="o"&gt;[&lt;/span&gt;:TAG&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Command Options
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;-m&lt;/code&gt;, &lt;code&gt;--message&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Adds a commit message describing the changes made to the container&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;-a&lt;/code&gt;, &lt;code&gt;--author&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Sets the author name and email for the new image (for example, &lt;code&gt;"Alice &amp;lt;alice@example.com&amp;gt;"&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;-p&lt;/code&gt;, &lt;code&gt;--pause&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Pauses the container during the commit process (enabled by default)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;-c&lt;/code&gt;, &lt;code&gt;--change&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Applies Dockerfile instructions such as &lt;code&gt;CMD&lt;/code&gt;, &lt;code&gt;ENV&lt;/code&gt;, or &lt;code&gt;EXPOSE&lt;/code&gt; to the new image&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;code&gt;docker container commit&lt;/code&gt; captures internal container changes but excludes data stored in mounted volumes or external storage.&lt;/p&gt;

&lt;h2&gt;
  
  
  Commit Changes to a New Docker Image
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Run a container from a base image with an interactive terminal session:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ docker container run -it ubuntu /bin/bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This pulls the latest Ubuntu image from Docker Hub if it isn't already available locally, and opens a Bash shell as the root user.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Inside the container, make your changes — for example, update the package list and install Nmap:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="c"&gt;# apt update &amp;amp;&amp;amp; apt install nmap -y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Exit the container:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="c"&gt;# exit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The container stops running, but Docker retains its state so you can commit the changes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. List all containers to find the one you just modified:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ docker container ls -a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CONTAINER ID   IMAGE     COMMAND       CREATED              STATUS                      PORTS     NAMES
fbd1f006ee67   ubuntu    "/bin/bash"   About a minute ago   Exited (0) 17 seconds ago             gracious_dijkstra
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Copy the container ID from the list — you'll use it in the next step.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Commit the container as a new image:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ docker container commit -m &lt;span class="s2"&gt;"Installed Nmap"&lt;/span&gt; fbd1f006ee67 ubuntu-with-nmap:v1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;fbd1f006ee67&lt;/code&gt; with your container ID, and &lt;code&gt;ubuntu-with-nmap:v1&lt;/code&gt; with your desired image name and tag. Docker returns the new image ID if the command runs without errors:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sha256:4ab8382015ea03a117a76a38dab41d6e291ecaad3b570d018d336dc5c81b9ac7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6. Confirm the image was created:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ docker image ls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;REPOSITORY         TAG       IMAGE ID       CREATED          SIZE
ubuntu-with-nmap   v1        4ab8382015ea   31 seconds ago   158MB
ubuntu             latest    a0e45e2ce6e6   13 days ago      78.1MB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  When to Commit Changes
&lt;/h2&gt;

&lt;p&gt;Use &lt;code&gt;docker container commit&lt;/code&gt; to capture changes made inside a running container and save them as a new image. This is useful for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Installing tools or packages&lt;/strong&gt;: Install additional utilities or custom scripts inside a container, then save the configured environment for later use or deployment&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Applying configuration changes&lt;/strong&gt;: Modify system settings or environment variables, then commit those changes to preserve the setup&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Capturing a debugging or testing state&lt;/strong&gt;: Troubleshoot or test inside a container, then commit the exact state to replicate the environment elsewhere or share it with your team&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Creating a snapshot before changes&lt;/strong&gt;: Save a point-in-time version of a container before applying further updates, so you can roll back if needed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;docker container commit&lt;/code&gt; is useful for quick snapshots and small-scale workflows, but it isn't ideal for production environments. For consistent, repeatable image builds in team-based or production deployments, use Dockerfiles with version control — they offer better visibility, traceability, and control over image configuration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Push your new image to a container registry with &lt;code&gt;docker image tag&lt;/code&gt; and &lt;code&gt;docker image push&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Convert a frequently-committed workflow into a Dockerfile for repeatable, version-controlled builds&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;docker history&lt;/code&gt; to inspect the layers of your newly committed image&lt;/li&gt;
&lt;li&gt;Clean up unused containers and images with &lt;code&gt;docker system prune&lt;/code&gt; once you've confirmed the new image works&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the full guide with additional tips, visit the original article on &lt;strong&gt;&lt;a href="https://docs.vultr.com/how-to-commit-changes-to-an-image-in-docker" rel="noopener noreferrer"&gt;Vultr Docs&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>cli</category>
      <category>containers</category>
      <category>devops</category>
    </item>
    <item>
      <title>Extracting Files Using Tar in Linux</title>
      <dc:creator>Sanskriti Harmukh</dc:creator>
      <pubDate>Fri, 20 Nov 2026 01:27:02 +0000</pubDate>
      <link>https://dev.to/vultr/extracting-files-using-tar-in-linux-4fok</link>
      <guid>https://dev.to/vultr/extracting-files-using-tar-in-linux-4fok</guid>
      <description>&lt;p&gt;Tar, short for Tape Archive, is a built-in Linux utility for creating and managing archives by combining multiple files into a single &lt;code&gt;.tar&lt;/code&gt; file. The &lt;code&gt;tar&lt;/code&gt; command creates, compresses, and extracts archives in several formats, giving you an organized way to manage large amounts of data. This guide covers the &lt;code&gt;tar&lt;/code&gt; command syntax and options, then walks through creating a sample archive, listing its contents, and extracting files from compressed and uncompressed archives, including &lt;code&gt;tar.gz&lt;/code&gt;, &lt;code&gt;tar.bz2&lt;/code&gt;, and &lt;code&gt;tar.xz&lt;/code&gt;. By the end, you'll be able to create, inspect, and extract tar archives on any Linux system.&lt;/p&gt;




&lt;h2&gt;
  
  
  The &lt;code&gt;tar&lt;/code&gt; Command Syntax
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ tar &lt;span class="o"&gt;[&lt;/span&gt;options&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;archive-file&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;file or directory to extract&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the command above:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;[options]&lt;/code&gt;: Command line options that specify and modify the &lt;code&gt;tar&lt;/code&gt; command's functionality&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;[archive-file]&lt;/code&gt;: The target archive name, such as &lt;code&gt;.tar&lt;/code&gt;, &lt;code&gt;.tar.gz&lt;/code&gt;, or &lt;code&gt;.tar.bz2&lt;/code&gt;, depending on the compression method&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;[file or directory to extract]&lt;/code&gt;: Optional files or directories to extract from the archive; you can specify multiple&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;tar&lt;/code&gt; Command Options
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;c&lt;/code&gt;: Creates a new archive&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-x&lt;/code&gt;: Extracts files from an archive&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-f&lt;/code&gt;: Specifies the target archive&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-v&lt;/code&gt;: Verbose mode; displays the &lt;code&gt;tar&lt;/code&gt; command's progress&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-t&lt;/code&gt;: Lists the archive contents&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-z&lt;/code&gt;: Enables Gzip compression&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-j&lt;/code&gt;: Enables Bzip2 compression&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-J&lt;/code&gt;: Enables XZ compression&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Create an Archive Using Tar
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Switch to your user's home directory:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="nb"&gt;cd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Create a sample &lt;code&gt;tar_dir&lt;/code&gt; directory:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ mkdir tar_dir
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Switch to the new &lt;code&gt;tar_dir&lt;/code&gt; directory:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="nb"&gt;cd&lt;/span&gt; tar_dir
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Create sample files:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ touch file.txt file1.txt file2.txt file3.txt nil.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Create a new &lt;code&gt;.tar&lt;/code&gt; archive with all the files:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ tar -cvf archive.tar file.txt file1.txt file2.txt file3.txt nil.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the command above, &lt;code&gt;-c&lt;/code&gt; creates a new archive, &lt;code&gt;v&lt;/code&gt; displays progress, &lt;code&gt;f&lt;/code&gt; specifies the archive filename, and the file list specifies what to add.&lt;/p&gt;

&lt;h2&gt;
  
  
  List Archive Contents Using Tar
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. List the contents of &lt;code&gt;archive.tar&lt;/code&gt;:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ tar -tf archive.tar
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;file.txt
file1.txt
file2.txt
file3.txt
nil.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-t&lt;/code&gt; option lists the archive contents while &lt;code&gt;f&lt;/code&gt; specifies the target archive.&lt;/p&gt;

&lt;h3&gt;
  
  
  Search Specific Files in an Archive
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1. List the archive and filter the output with &lt;code&gt;grep&lt;/code&gt;:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ tar -tf archive.tar &lt;span class="o"&gt;|&lt;/span&gt; grep &lt;span class="s2"&gt;"file"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;file.txt
file1.txt
file2.txt
file3.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Extract Files Using the &lt;code&gt;tar&lt;/code&gt; Command
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Extract all files from &lt;code&gt;archive.tar&lt;/code&gt;:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ tar -xvf archive.tar
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;file.txt
file1.txt
file2.txt
file3.txt
nil.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Extract specific files, such as &lt;code&gt;file1.txt&lt;/code&gt; and &lt;code&gt;file3.txt&lt;/code&gt;:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ tar -xvf archive.tar file1.txt file3.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Extract Files to a Specific Directory Using Tar
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;tar&lt;/code&gt; extracts files to your working directory by default unless you specify a target with the &lt;code&gt;-C&lt;/code&gt; option.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Create a new &lt;code&gt;extract_dir&lt;/code&gt; directory:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ mkdir extract_dir
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Extract &lt;code&gt;archive.tar&lt;/code&gt; into the &lt;code&gt;extract_dir&lt;/code&gt; directory:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ tar -xf archive.tar -C extract_dir
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Navigate to the &lt;code&gt;extract_dir&lt;/code&gt; directory:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="nb"&gt;cd&lt;/span&gt; extract_dir
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. List the files to verify the extraction:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ ls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;file1.txt  file2.txt  file3.txt  file.txt  nil.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Extract Files From Compressed Archives Using Tar
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Extract a Gzip-compressed &lt;code&gt;.tar.gz&lt;/code&gt; or &lt;code&gt;.tgz&lt;/code&gt; archive with the &lt;code&gt;-z&lt;/code&gt; option:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ tar -xzf archive.tar.gz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Extract a Bzip2-compressed &lt;code&gt;.tar.bz2&lt;/code&gt; archive with the &lt;code&gt;-j&lt;/code&gt; option:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ tar -xjf archive.tar.bz2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Extract an XZ-compressed &lt;code&gt;.tar.xz&lt;/code&gt; archive with the &lt;code&gt;-J&lt;/code&gt; option:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ tar -xJf archive.tar.xz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Create compressed archives directly with &lt;code&gt;tar -czf&lt;/code&gt;, &lt;code&gt;-cjf&lt;/code&gt;, or &lt;code&gt;-cJf&lt;/code&gt; for distribution or backups&lt;/li&gt;
&lt;li&gt;Combine &lt;code&gt;tar&lt;/code&gt; with &lt;code&gt;scp&lt;/code&gt; or &lt;code&gt;rsync&lt;/code&gt; to transfer archives between servers efficiently&lt;/li&gt;
&lt;li&gt;Schedule periodic &lt;code&gt;tar&lt;/code&gt; backups of important directories with cron&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;man tar&lt;/code&gt; for the full list of options and advanced usage patterns&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the full guide with additional tips, visit the original article on &lt;strong&gt;&lt;a href="https://docs.vultr.com/how-to-extract-files-using-tar-in-linux" rel="noopener noreferrer"&gt;Vultr Docs&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>cli</category>
      <category>tar</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Using the Netstat Command in Linux</title>
      <dc:creator>Sanskriti Harmukh</dc:creator>
      <pubDate>Fri, 20 Nov 2026 01:26:37 +0000</pubDate>
      <link>https://dev.to/vultr/using-the-netstat-command-in-linux-o8i</link>
      <guid>https://dev.to/vultr/using-the-netstat-command-in-linux-o8i</guid>
      <description>&lt;p&gt;&lt;code&gt;netstat&lt;/code&gt;, short for network statistics, is a command-line tool for diagnosing network issues and gathering network statistics. It displays active connections and listening sockets for TCP, UDP, and UNIX domain sockets, lists associated ports, shows basic network interface statistics, and prints the kernel's routing table. This guide covers installing &lt;code&gt;netstat&lt;/code&gt; and using it to monitor connections, identify open ports, and troubleshoot network issues. By the end, you'll be able to read &lt;code&gt;netstat&lt;/code&gt; output and use its most common options to monitor and diagnose networking on a Linux system.&lt;/p&gt;




&lt;h2&gt;
  
  
  Install &lt;code&gt;netstat&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;netstat&lt;/code&gt; command is part of the &lt;code&gt;net-tools&lt;/code&gt; package.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Install &lt;code&gt;net-tools&lt;/code&gt;:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;On Debian/Ubuntu:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ sudo apt install net-tools -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On RHEL distributions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ sudo dnf install net-tools -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On Arch Linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ sudo pacman -Sy net-tools
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On SUSE Linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ sudo zypper install net-tools -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On Alpine Linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ sudo apk add net-tools
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Verify the installation:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;net-tools 2.10
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;code&gt;netstat&lt;/code&gt; Command Syntax
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ netstat &lt;span class="o"&gt;[&lt;/span&gt;OPTIONS&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The options modify the command's behavior. Without any options, &lt;code&gt;netstat&lt;/code&gt; displays a list of open sockets.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;netstat&lt;/code&gt; Command Output Anatomy
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. View all active connections on your system:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ netstat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address        State
tcp        0      0 hostname:49922          example.com:https      ESTABLISHED
tcp        0      0 hostname:44568          cdn-1-0-0-127:https    ESTABLISHED
...
...
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  3      [ ]         STREAM     CONNECTED     7931     /run/user/1050/bus
unix  3      [ ]         STREAM     CONNECTED     7835     /run/dbus/system_bus_socket
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output has two sections:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Active Internet Connections&lt;/strong&gt;: TCP and UDP connections between your localhost &lt;code&gt;hostname&lt;/code&gt; and remote hosts such as &lt;code&gt;example.com&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Active UNIX domain sockets&lt;/strong&gt;: Local UNIX sockets that are open&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Column reference:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Proto&lt;/strong&gt;: The active network protocol — &lt;code&gt;tcp&lt;/code&gt;, &lt;code&gt;udp&lt;/code&gt;, or &lt;code&gt;unix&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Recv-Q&lt;/strong&gt;: Bytes of data received by the kernel but not yet read by the application&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Send-Q&lt;/strong&gt;: Bytes queued by the application to send that haven't been acknowledged by the target&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Local Address&lt;/strong&gt;: The system hostname, IP address, and port&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Foreign Address&lt;/strong&gt;: The reverse lookup of the remote host&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;State&lt;/strong&gt;: The connection state (&lt;code&gt;ESTABLISHED&lt;/code&gt; denotes an established connection)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;RefCnt&lt;/strong&gt;: How many users or connections are connected to the socket&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Flags&lt;/strong&gt;: Flags related to UNIX sockets&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Type&lt;/strong&gt;: The socket type, such as &lt;code&gt;STREAM&lt;/code&gt;, &lt;code&gt;DGRAM&lt;/code&gt;, &lt;code&gt;SEQPACKET&lt;/code&gt;, or &lt;code&gt;RAW&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;I-Node&lt;/strong&gt;: The inode number associated with the &lt;code&gt;unix&lt;/code&gt; socket&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Path&lt;/strong&gt;: The filesystem path associated with the &lt;code&gt;unix&lt;/code&gt; socket&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;netstat&lt;/code&gt; without any options shows only non-listening sockets.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;netstat&lt;/code&gt; Options
&lt;/h2&gt;

&lt;p&gt;The most commonly used options:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;--listening&lt;/code&gt; or &lt;code&gt;-l&lt;/code&gt;: Displays listening sockets&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--all&lt;/code&gt; or &lt;code&gt;-a&lt;/code&gt;: Displays both established and non-established connections&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--tcp&lt;/code&gt; or &lt;code&gt;-t&lt;/code&gt;: Displays TCP sockets&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--udp&lt;/code&gt; or &lt;code&gt;-u&lt;/code&gt;: Displays UDP sockets&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--numeric&lt;/code&gt; or &lt;code&gt;-n&lt;/code&gt;: Displays port numbers and IP addresses instead of names&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--program&lt;/code&gt; or &lt;code&gt;-p&lt;/code&gt;: Displays the PID/program name associated with each socket (requires &lt;code&gt;sudo&lt;/code&gt; for systemwide processes)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;netstat&lt;/code&gt; doesn't list listening sockets without the &lt;code&gt;-l&lt;/code&gt; or &lt;code&gt;-a&lt;/code&gt; option.&lt;/p&gt;

&lt;h3&gt;
  
  
  Display Open Connections With Process IDs
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ sudo netstat -p
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address      State       PID/Program name
tcp        0      0 hostname:55604          2.0.0.127.in-a:https ESTABLISHED 2320/firefox
tcp        0      0 hostname:40128          3.0.0.127.i:https    ESTABLISHED 33638/app --st
...
...
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags       Type       State         I-Node   PID/Program name     Path
unix  3      [ ]         STREAM     CONNECTED     12358    750/pipewire         /run/user/1050/pipewire-0
unix  3      [ ]         STREAM     CONNECTED     31580    3898/speech-dispatc  /run/user/1050/speech-dispatcher/speechd.sock
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  View Open Ports
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ sudo netstat -ltup
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 localhost:mshvlm        0.0.0.0:*               LISTEN      763/mpd
udp        0      0 0.0.0.0:35069           0.0.0.0:*                           1451/firefox
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Display the Routing Table
&lt;/h3&gt;



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

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
default         _gateway        0.0.0.0         UG        0 0          0 enp1s0
192.168.10.2.ch _gateway        255.255.255.255 UGH       0 0          0 enp1s0
192.168.10.1    0.0.0.0         255.255.254.0   U         0 0          0 enp1s0
_gateway        0.0.0.0         255.255.255.255 UH        0 0          0 enp1s0
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 wlp4s0
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Column reference:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Destination&lt;/strong&gt;: Destination IP or hostname&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gateway&lt;/strong&gt;: The next hop on the route&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Genmask&lt;/strong&gt;: The network mask of the route&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Flags&lt;/strong&gt;: &lt;code&gt;U&lt;/code&gt; (route is up), &lt;code&gt;H&lt;/code&gt; (destination is a specific host), &lt;code&gt;G&lt;/code&gt; (destination is a gateway)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MSS&lt;/strong&gt;: Maximum segment size — the maximum payload size the socket receives&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Window&lt;/strong&gt;: The TCP window size&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;irtt&lt;/strong&gt;: Initial round trip time of packets for a connection&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Iface&lt;/strong&gt;: The network interface of the route&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the example output above, traffic to &lt;code&gt;0.0.0.0&lt;/code&gt; routes through the &lt;code&gt;wlp4s0&lt;/code&gt; interface, with a default gateway of &lt;code&gt;192.168.1.1&lt;/code&gt; reached via &lt;code&gt;wlp4s0&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Display Network Interface Statistics
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ netstat -i
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Kernel Interface table
Iface             MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
lo              65536     6111      0      0 0          6111      0      0      0 LRU
wlp4s0           1500  1164542      0      0 0        822802      0     38      0 BMRU
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Column reference:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Iface&lt;/strong&gt;: The network interface name&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MTU&lt;/strong&gt;: The maximum transmission unit in bytes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;RX-OK&lt;/strong&gt;: Count of successfully received packets&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;RX-ERR&lt;/strong&gt;: Count of error packets received&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;RX-DRP&lt;/strong&gt;: Count of packets dropped by the interface&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;RX-OVR&lt;/strong&gt;: Count of data packets the interface couldn't handle&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TX-OK&lt;/strong&gt;: Size of successfully transmitted packets&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TX-ERR&lt;/strong&gt;: Count of error transmitted packets&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TX-DRP&lt;/strong&gt;: Count of packets dropped by the transmit queue&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TX-OVR&lt;/strong&gt;: Similar to RX-OVR, but for transmitted data&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Flg&lt;/strong&gt;: &lt;code&gt;B&lt;/code&gt; (broadcast address set), &lt;code&gt;L&lt;/code&gt; (loopback interface), &lt;code&gt;M&lt;/code&gt; (promiscuous mode), &lt;code&gt;R&lt;/code&gt; (running interface), &lt;code&gt;U&lt;/code&gt; (interface is up)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  View All Active Network Connections
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ sudo netstat -apn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:6600          0.0.0.0:*               LISTEN      724/mpd
tcp        0      0 192.168.1.6:49928       172.6.0.4:443           ESTABLISHED 1148/firefox
...
...
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node   PID/Program name     Path
unix  3      [ ]         STREAM     CONNECTED     13452    893/dbus-broker      /run/user/1050/at-spi/bus_0
unix  2      [ ACC ]     STREAM     LISTENING     10355    724/mpd              /home/ndlr/.config/mpd/socket
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Where &lt;code&gt;-a&lt;/code&gt; shows all connections, &lt;code&gt;-p&lt;/code&gt; shows the PID and program name, and &lt;code&gt;-n&lt;/code&gt; shows numeric output.&lt;/p&gt;

&lt;h3&gt;
  
  
  Display Active TCP Connections
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ sudo netstat -aptn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:6600          0.0.0.0:*               LISTEN      724/mpd
tcp        0      0 192.168.1.6:49928       172.6.0.4:443           ESTABLISHED 1148/firefox
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Display Active UDP Connections
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ sudo netstat -apun
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
udp        0      0 0.0.0.0:47697           0.0.0.0:*                           1148/firefox
udp        0      0 192.168.1.6:68          192.168.1.1:67          ESTABLISHED 601/NetworkManager
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Display Network Timer Data
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ netstat -ano
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       Timer
tcp        0      0 127.0.0.54:53           0.0.0.0:*               LISTEN      off (0.00/0/0)
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      off (0.00/0/0)
...
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  3      [ ]         STREAM     CONNECTED     8613     /run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     8929     /run/dbus/system_bus_socket
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;Timer&lt;/code&gt; column displays timer data for the socket.&lt;/p&gt;

&lt;h3&gt;
  
  
  Display Listening Sockets
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ netstat -tuln
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 127.0.0.54:53           0.0.0.0:*               LISTEN        
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp6       0      0 :::22                   :::*                    LISTEN     
udp        0      0 127.0.0.54:53           0.0.0.0:*                          
udp        0      0 127.0.0.53:53           0.0.0.0:*                          
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Combine &lt;code&gt;netstat&lt;/code&gt; with &lt;code&gt;grep&lt;/code&gt; to filter output for a specific port or process&lt;/li&gt;
&lt;li&gt;Compare &lt;code&gt;netstat&lt;/code&gt; output with the newer &lt;code&gt;ss&lt;/code&gt; command, which is faster on systems with many connections&lt;/li&gt;
&lt;li&gt;Set up a monitoring script that polls &lt;code&gt;netstat -tuln&lt;/code&gt; to alert on unexpected open ports&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;man 8 netstat&lt;/code&gt; for the full list of options and flags&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the full guide with additional tips, visit the original article on &lt;strong&gt;&lt;a href="https://docs.vultr.com/how-to-use-the-netstat-command-in-linux" rel="noopener noreferrer"&gt;Vultr Docs&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>networking</category>
      <category>cli</category>
      <category>sysadmin</category>
    </item>
    <item>
      <title>Zipping and Unzipping Files in Linux</title>
      <dc:creator>Sanskriti Harmukh</dc:creator>
      <pubDate>Fri, 20 Nov 2026 01:26:14 +0000</pubDate>
      <link>https://dev.to/vultr/zipping-and-unzipping-files-in-linux-55l4</link>
      <guid>https://dev.to/vultr/zipping-and-unzipping-files-in-linux-55l4</guid>
      <description>&lt;p&gt;&lt;code&gt;zip&lt;/code&gt; and &lt;code&gt;unzip&lt;/code&gt; are command-line utilities for compressing and extracting files and directories on Linux systems. &lt;code&gt;zip&lt;/code&gt; combines multiple files and directories into a single compressed archive to save storage space and simplify file management, while &lt;code&gt;unzip&lt;/code&gt; extracts the archived contents when needed. This guide covers installing both utilities and using them to compress individual files, archive entire directories, and extract archive contents. By the end, you'll have &lt;code&gt;zip&lt;/code&gt; and &lt;code&gt;unzip&lt;/code&gt; installed and working archive and extraction workflows for both individual files and whole directory trees.&lt;/p&gt;




&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Access to a Linux server as a non-root sudo user&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Install Zip and Unzip
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;zip&lt;/code&gt; and &lt;code&gt;unzip&lt;/code&gt; utilities are available through the default package managers on most Linux distributions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ubuntu &amp;amp; Debian:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Update the &lt;code&gt;apt&lt;/code&gt; package index:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ sudo apt update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Install &lt;code&gt;zip&lt;/code&gt; and &lt;code&gt;unzip&lt;/code&gt;:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ sudo apt install -y zip unzip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;CentOS/AlmaLinux/Rocky Linux/Fedora:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ sudo dnf install -y zip unzip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you're using an older version of Rocky Linux, AlmaLinux, or CentOS that doesn't support &lt;code&gt;dnf&lt;/code&gt;, replace &lt;code&gt;dnf&lt;/code&gt; with &lt;code&gt;yum&lt;/code&gt; in the command above.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Arch Linux:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ sudo pacman -S zip unzip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;openSUSE:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ sudo zypper install -y zip unzip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Alpine Linux:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Update the &lt;code&gt;apk&lt;/code&gt; package index:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ sudo apk update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Install &lt;code&gt;zip&lt;/code&gt; and &lt;code&gt;unzip&lt;/code&gt;:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ sudo apk add zip unzip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;code&gt;zip&lt;/code&gt; Command Syntax
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ zip &lt;span class="o"&gt;[&lt;/span&gt;OPTIONS&lt;span class="o"&gt;]&lt;/span&gt;... &lt;span class="o"&gt;[&lt;/span&gt;COMPRESSED_FILENAME&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;FILES/DIRS TO COMPRESS&lt;span class="o"&gt;]&lt;/span&gt;...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Where:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;[OPTIONS]&lt;/code&gt; modify the command behavior and are optional&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;[COMPRESSED_FILENAME]&lt;/code&gt; is the name of the archive file the command creates&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;[FILES/DIRS TO COMPRESS]&lt;/code&gt; is the list of files or directories to archive&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;zip&lt;/code&gt; Command Usage
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Compress a single file into a &lt;code&gt;.zip&lt;/code&gt; archive:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ zip archive-name.zip file1.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Add multiple files to a new or existing archive:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ zip archive-name.zip file1.txt file2.txt file3.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the archive doesn't exist, this creates a new one; if it exists, it updates the archive with the specified files.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Set the compression level (&lt;code&gt;-0&lt;/code&gt; for fastest/no compression, &lt;code&gt;-9&lt;/code&gt; for maximum compression):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ zip -9 archive-name.zip file.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Password-protect an archive with the &lt;code&gt;-P&lt;/code&gt; option:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ zip -P your_password archive-name.zip file4.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Exclude specific files from the archive with the &lt;code&gt;-x&lt;/code&gt; flag:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ zip archive-name.zip *.txt -x secret.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This adds all &lt;code&gt;.txt&lt;/code&gt; files in the directory to the archive except &lt;code&gt;secret.txt&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Update files in the archive only if the source file is newer, with the &lt;code&gt;-u&lt;/code&gt; flag:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ zip -u archive-name.zip updatedfile.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;7. View detailed output while compressing with the &lt;code&gt;-v&lt;/code&gt; flag:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ zip -v archive-name.zip file1.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;code&gt;unzip&lt;/code&gt; Command Syntax
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ unzip &lt;span class="o"&gt;[&lt;/span&gt;OPTIONS&lt;span class="o"&gt;]&lt;/span&gt;... &lt;span class="o"&gt;[&lt;/span&gt;ZIP_FILENAME&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;MEMBER FILES/DIRS&lt;span class="o"&gt;]&lt;/span&gt;...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Where:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;[OPTIONS]&lt;/code&gt; modify how the contents are extracted and are optional&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;[ZIP_FILENAME]&lt;/code&gt; is the &lt;code&gt;.zip&lt;/code&gt; file to extract entirely or partially&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;[MEMBER FILES/DIRS]&lt;/code&gt; are files or directories within the archive to extract; if omitted, the command extracts everything&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;unzip&lt;/code&gt; Command Usage
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Extract all files from an archive into the working directory:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ unzip archive-name.zip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Extract a single file instead of the full archive:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ unzip archive-name.zip file1.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Extract to a specific destination with the &lt;code&gt;-d&lt;/code&gt; flag:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ unzip archive-name.zip -d /path/to/destination
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Preview the files inside an archive without extracting with the &lt;code&gt;-l&lt;/code&gt; flag:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ unzip -l archive-name.zip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Extract multiple specific files by listing them after the archive name:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ unzip archive-name.zip file1.txt updatedfile.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6. Overwrite existing files automatically with the &lt;code&gt;-o&lt;/code&gt; flag:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ unzip -o archive-name.zip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;7. Skip files that already exist in the destination with the &lt;code&gt;-n&lt;/code&gt; flag:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ unzip -n archive-name.zip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;8. View detailed output during extraction with the &lt;code&gt;-v&lt;/code&gt; flag:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ unzip -v archive-name.zip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Zip a Directory
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Compress a directory and all its contents with the &lt;code&gt;-r&lt;/code&gt; flag:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ zip -r archive-name.zip directory-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Exclude specific files, file types, or folders during compression with the &lt;code&gt;-x&lt;/code&gt; flag:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ zip -r archive-name.zip directory-name -x &lt;span class="s2"&gt;"*.log"&lt;/span&gt; &lt;span class="s2"&gt;"*.tmp"&lt;/span&gt; &lt;span class="s2"&gt;"cache/*"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Combine multiple directories into a single zip file:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ zip -r archive-name.zip dir1 dir2 dir3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Compress the entire working directory using a single dot:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ zip -r archive-name.zip .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Unzip a Directory
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Extract a full directory structure into the working directory:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ unzip archive-name.zip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Extract into a specific location with the &lt;code&gt;-d&lt;/code&gt; flag:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ unzip archive-name.zip -d /path/to/destination
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Automatically overwrite existing files and directories with the &lt;code&gt;-o&lt;/code&gt; flag:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ unzip -o archive-name.zip -d /path/to/destination
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Skip overwriting existing files or directories with the &lt;code&gt;-n&lt;/code&gt; flag:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ unzip -n archive-name.zip -d /path/to/destination
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Automate periodic backups by scripting &lt;code&gt;zip -r&lt;/code&gt; against a cron schedule&lt;/li&gt;
&lt;li&gt;Combine &lt;code&gt;zip&lt;/code&gt; with &lt;code&gt;scp&lt;/code&gt; or &lt;code&gt;rsync&lt;/code&gt; to transfer compressed archives between servers&lt;/li&gt;
&lt;li&gt;Explore &lt;code&gt;tar&lt;/code&gt; for archiving on systems where &lt;code&gt;.tar.gz&lt;/code&gt; is the preferred format&lt;/li&gt;
&lt;li&gt;Add password protection to any archive that contains sensitive files before sharing it&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the full guide with additional tips, visit the original article on &lt;strong&gt;&lt;a href="https://docs.vultr.com/how-to-zip-and-unzip-files-in-linux" rel="noopener noreferrer"&gt;Vultr Docs&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>cli</category>
      <category>compression</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Using the SCP Command in Linux</title>
      <dc:creator>Sanskriti Harmukh</dc:creator>
      <pubDate>Fri, 20 Nov 2026 01:25:59 +0000</pubDate>
      <link>https://dev.to/vultr/using-the-scp-command-in-linux-gc6</link>
      <guid>https://dev.to/vultr/using-the-scp-command-in-linux-gc6</guid>
      <description>&lt;p&gt;&lt;code&gt;scp&lt;/code&gt; stands for Secure Copy Protocol. It lets you securely transfer files and directories between Linux hosts over an encrypted SSH connection, and unlike plain &lt;code&gt;cp&lt;/code&gt;, it also verifies data integrity during the transfer. This guide covers the &lt;code&gt;scp&lt;/code&gt; command syntax, its most useful options, and practical examples for copying files and directories between a local and a remote server, plus how to set up SSH key authentication for passwordless transfers. By the end, you'll have working &lt;code&gt;scp&lt;/code&gt; workflows for transferring single files, whole directories, and tar archives between two Linux systems, both with and without a password prompt.&lt;/p&gt;




&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Two Linux servers (one acting as local, one as remote) that you can reach over SSH&lt;/li&gt;
&lt;li&gt;SSH access configured on both servers&lt;/li&gt;
&lt;li&gt;Both servers updated to the latest packages&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The &lt;code&gt;scp&lt;/code&gt; Command Syntax
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ scp &lt;span class="o"&gt;[&lt;/span&gt;options&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;source&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;destination&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the command above:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;[options]&lt;/code&gt;: Accepts optional flags to modify the command's behavior&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;[source]&lt;/code&gt;: Specifies the file or directory to copy&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;[destination]&lt;/code&gt;: Sets the target location where you want to place the files&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Common &lt;code&gt;scp&lt;/code&gt; Command Options
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-P&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Specifies the port to connect on the remote host&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-p&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Preserves the original file's modification times, access times, and modes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-r&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Recursively copies entire directories&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-q&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Quiet mode; suppresses non-error messages&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-C&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Enables compression&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-l&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Limits the bandwidth used during the transfer&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-v&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Verbose mode; displays detailed debugging messages&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-i&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Sets the private key location to use with a public key for authentication&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Create Sample Directories and Files
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Create three sample &lt;code&gt;.txt&lt;/code&gt; files on your local server:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ touch file1.txt file2.txt file3.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Create a sample &lt;code&gt;dir&lt;/code&gt; directory on your local server:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ mkdir dir
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Create three sample &lt;code&gt;.txt&lt;/code&gt; files on the remote server:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ touch file4.txt file5.txt file6.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Create &lt;code&gt;dir1&lt;/code&gt; and &lt;code&gt;dir2&lt;/code&gt; sample directories on the remote server:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ mkdir dir1 dir2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Transfer Files and Directories Using SCP
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Copy &lt;code&gt;file1.txt&lt;/code&gt; from your local server to the remote server:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ scp file1.txt linuxuser2@remote_server:/home/linuxuser2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This securely copies &lt;code&gt;file1.txt&lt;/code&gt; to the remote user's home directory. By default, &lt;code&gt;scp&lt;/code&gt; copies files to the user's home directory unless you specify another directory. Enter &lt;code&gt;yes&lt;/code&gt; to accept the remote server's fingerprint key when prompted.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Copy &lt;code&gt;file4.txt&lt;/code&gt; from the remote server to your local server:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ scp linuxuser2@remote_server:/home/linuxuser2/file4.txt /home/linuxuser1/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Copy the &lt;code&gt;dir&lt;/code&gt; directory from the local server to the remote server using the recursive &lt;code&gt;-r&lt;/code&gt; option:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ scp -r dir linuxuser2@remote_server:/home/linuxuser2/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This recursively copies the &lt;code&gt;dir&lt;/code&gt; directory, including all files and subdirectories, into the &lt;code&gt;linuxuser2&lt;/code&gt; home directory on the remote server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Copy the &lt;code&gt;dir1&lt;/code&gt; directory from the remote server to your local server's home directory:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ scp -r linuxuser2@remote_server:/home/linuxuser2/dir1 /home/linuxuser1/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Enable Passwordless Authentication Using an SSH Key
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;scp&lt;/code&gt; uses password authentication by default. SSH key-based authentication lets you transfer files without entering a password each time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Generate a new SSH key pair on your local server:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ ssh-keygen -t rsa -b 4096
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Press Enter to accept the default private key file location and set an optional passphrase when prompted.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Copy your public key to the remote server:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ ssh-copy-id linuxuser2@remote_server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enter your remote user password when prompted to copy the public key.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Access the remote server using SSH and verify that you're not prompted for a password:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ ssh linuxuser2@remote_server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Transfer Files Using SCP with SSH Key Authentication
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Copy &lt;code&gt;file2.txt&lt;/code&gt; from your local server to the &lt;code&gt;dir2&lt;/code&gt; directory on the remote server:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ scp file2.txt linuxuser2@remote_server:/home/linuxuser2/dir2/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Copy the &lt;code&gt;dir2&lt;/code&gt; directory from the remote server to your local server:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ scp -r linuxuser2@remote_server:/home/linuxuser2/dir2 /home/linuxuser1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Use SCP with Advanced Options
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Preserve file attributes during transfer with the &lt;code&gt;-p&lt;/code&gt; option:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ scp -p file3.txt linuxuser2@remote_server:/home/linuxuser2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This copies &lt;code&gt;file3.txt&lt;/code&gt; to the remote user's home directory while keeping the original timestamps and file permissions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Enable compression during transfer with the &lt;code&gt;-C&lt;/code&gt; option:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ scp -C file1.txt linuxuser2@remote_server:/home/linuxuser2/dir2/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This copies &lt;code&gt;file1.txt&lt;/code&gt; to the &lt;code&gt;dir2&lt;/code&gt; directory and compresses the data during transfer to speed up the process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Limit the transfer bandwidth in kilobits per second (Kbps) with the &lt;code&gt;-l&lt;/code&gt; option:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ scp -l 500 file2.txt linuxuser2@remote_server:/home/linuxuser2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This limits the transfer speed to &lt;code&gt;500&lt;/code&gt; Kbps to avoid overusing network resources.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Display detailed debugging messages in verbose mode with the &lt;code&gt;-v&lt;/code&gt; option:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ scp -v file3.txt linuxuser2@remote_server:/home/linuxuser2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Specify a private key for authentication with the &lt;code&gt;-i&lt;/code&gt; option:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ scp -i /path/to/private_key file1.txt user@remote_server:/home/linuxuser2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;/path/to/private_key&lt;/code&gt; with your actual private key path. This is useful when you use multiple SSH keys and need a specific one to establish the connection. Run the following command in your home directory to view the default SSH private key location:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ ls -l /.ssh/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6. Transfer files using a specific SSH port with the &lt;code&gt;-P&lt;/code&gt; option:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ scp -P 22 file3.txt linuxuser2@remote_server:/home/linuxuser2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is important when the SSH daemon runs on a custom port on the remote server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. Transfer archived files over SCP's underlying SSH connection using &lt;code&gt;tar&lt;/code&gt;:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ tar czf - dir &lt;span class="o"&gt;|&lt;/span&gt; ssh linuxuser2@remote_server &lt;span class="s1"&gt;'tar xzf - -C /home/linuxuser2/dir1'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This compresses the &lt;code&gt;dir&lt;/code&gt; directory and streams the data over SSH to the remote server, where &lt;code&gt;tar xzf - -C&lt;/code&gt; extracts it into the &lt;code&gt;dir1&lt;/code&gt; directory for efficient, bandwidth-saving transfers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Explore the &lt;code&gt;find&lt;/code&gt; command in Linux to quickly locate files before transferring them&lt;/li&gt;
&lt;li&gt;Automate recurring transfers with a cron job that runs &lt;code&gt;scp&lt;/code&gt; on a schedule&lt;/li&gt;
&lt;li&gt;Combine &lt;code&gt;scp&lt;/code&gt; with &lt;code&gt;rsync&lt;/code&gt; for incremental transfers that only copy changed files&lt;/li&gt;
&lt;li&gt;Harden SSH access further by disabling password authentication once key-based login is confirmed working&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the full guide with additional tips, visit the original article on &lt;strong&gt;&lt;a href="https://docs.vultr.com/how-to-use-the-scp-command-in-linux" rel="noopener noreferrer"&gt;Vultr Docs&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>ssh</category>
      <category>networking</category>
      <category>cli</category>
    </item>
    <item>
      <title>Enabling Observability in NVIDIA Dynamo Inference Pipelines</title>
      <dc:creator>Sanskriti Harmukh</dc:creator>
      <pubDate>Fri, 20 Nov 2026 01:25:32 +0000</pubDate>
      <link>https://dev.to/vultr/enabling-observability-in-nvidia-dynamo-inference-pipelines-52j3</link>
      <guid>https://dev.to/vultr/enabling-observability-in-nvidia-dynamo-inference-pipelines-52j3</guid>
      <description>&lt;p&gt;&lt;a href="https://docs.nvidia.com/dynamo/getting-started/quickstart" rel="noopener noreferrer"&gt;NVIDIA Dynamo&lt;/a&gt; is an open-source inference framework for deploying large-scale generative AI models across multi-node, multi-GPU environments. Distributed inference systems require comprehensive observability to track request flows, monitor resource utilization, and troubleshoot failures across multiple workers. Dynamo provides built-in observability through metrics (Prometheus), distributed tracing (OpenTelemetry/Tempo), and structured logging. This guide covers enabling and configuring observability in NVIDIA Dynamo inference pipelines for both aggregated serving (single-worker) and disaggregated serving (separate prefill/decode workers). By the end, you'll have Prometheus metrics, OpenTelemetry traces, and Grafana dashboards running against a live Dynamo inference deployment.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before you begin, ensure you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Have access to a GPU-enabled server with NVIDIA GPUs installed and the NVIDIA Container Toolkit configured. Use a non-root user with sudo privileges.

&lt;ul&gt;
&lt;li&gt;1 GPU minimum for aggregated serving.&lt;/li&gt;
&lt;li&gt;4 GPUs for disaggregated serving.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Install &lt;a href="https://docs.docker.com/engine/install/" rel="noopener noreferrer"&gt;Docker Engine&lt;/a&gt; and &lt;a href="https://docs.docker.com/compose/install/" rel="noopener noreferrer"&gt;Docker Compose&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Create a &lt;a href="https://huggingface.co/join" rel="noopener noreferrer"&gt;Hugging Face account&lt;/a&gt; and generate an &lt;a href="https://huggingface.co/settings/tokens" rel="noopener noreferrer"&gt;access token&lt;/a&gt; for gated models like Llama.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Understanding NVIDIA Dynamo Observability
&lt;/h2&gt;

&lt;p&gt;Observability in NVIDIA Dynamo provides comprehensive monitoring capabilities through three interconnected systems that work together to provide visibility into inference pipeline performance and behavior.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Metrics&lt;/strong&gt; expose quantitative measurements through Prometheus endpoints on each Dynamo component. The frontend service exposes metrics including request counts, token processing rates, time-to-first-token (TTFT), and inter-token latency on port 8000. Backend workers expose component-level metrics including request duration, inflight requests, and KV cache statistics on their system status ports (default: 8081). The metrics system uses the Prometheus exposition format and includes labels (&lt;code&gt;dynamo_namespace&lt;/code&gt;, &lt;code&gt;dynamo_component&lt;/code&gt;, &lt;code&gt;dynamo_endpoint&lt;/code&gt;) to identify metric sources. All Dynamo-generated metrics use the &lt;code&gt;dynamo_*&lt;/code&gt; prefix for consistent identification.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Tracing&lt;/strong&gt; provides distributed request flow visualization using OpenTelemetry and Tempo. When enabled, Dynamo creates trace spans that follow requests across the frontend, prefill workers, and decode workers. Each trace includes a root &lt;code&gt;http-request&lt;/code&gt; span from the frontend, a &lt;code&gt;prefill_routing&lt;/code&gt; span for routing decisions, and &lt;code&gt;handle_payload&lt;/code&gt; spans for prefill and decode operations. Traces use OpenTelemetry Protocol (OTLP) to export data to Tempo, where Grafana displays flame graphs showing request timelines, component interactions, and processing durations. Traces include correlation IDs through the &lt;code&gt;x-request-id&lt;/code&gt; header, enabling request tracking across distributed components.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Logging&lt;/strong&gt; captures structured event data in JSONL format with trace context. When JSONL logging is enabled, each log entry includes &lt;code&gt;trace_id&lt;/code&gt;, &lt;code&gt;span_id&lt;/code&gt;, and &lt;code&gt;x_request_id&lt;/code&gt; fields that correlate logs with traces. The logging system supports configurable verbosity levels (ERROR, WARN, INFO, DEBUG, TRACE) and target-specific filtering. Logs are written to stderr and can be collected by log aggregation systems for centralized analysis.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. Clone the Dynamo Repository
&lt;/h2&gt;

&lt;p&gt;NVIDIA Dynamo provides deployment scripts, container utilities, and orchestration modules required to run inference workloads.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Clone the repository:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ git clone https://github.com/ai-dynamo/dynamo.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Navigate to the repository directory:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="nb"&gt;cd&lt;/span&gt; dynamo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Switch to the latest stable release:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ git checkout release/0.9.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Visit the &lt;a href="https://github.com/ai-dynamo/dynamo/releases/" rel="noopener noreferrer"&gt;Dynamo releases page&lt;/a&gt; to find the latest stable release version.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Start Infrastructure and Observability Services
&lt;/h2&gt;

&lt;p&gt;Dynamo's observability architecture requires both infrastructure components (etcd, NATS) and monitoring services (Prometheus, Grafana, Tempo, exporters). The infrastructure services provide service discovery and message passing, while the observability services collect metrics, store traces, and visualize data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Start the infrastructure services:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ docker compose -f deploy/docker-compose.yml up -d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Start the observability stack:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ docker compose -f deploy/docker-observability.yml up -d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Verify all services are running:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ docker compose -f deploy/docker-compose.yml ps &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; docker compose -f deploy/docker-observability.yml ps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All containers should be up and running with exposed ports for etcd, NATS, Grafana, Prometheus, Tempo, DCGM Exporter, and NATS Exporter. The services expose monitoring interfaces on the following ports:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Grafana&lt;/strong&gt;: &lt;code&gt;http://SERVER-IP:3000&lt;/code&gt; (username: &lt;code&gt;dynamo&lt;/code&gt;, password: &lt;code&gt;dynamo&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prometheus&lt;/strong&gt;: &lt;code&gt;http://SERVER-IP:9090&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tempo&lt;/strong&gt;: &lt;code&gt;http://SERVER-IP:3200&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DCGM Exporter&lt;/strong&gt;: &lt;code&gt;http://localhost:9401/metrics&lt;/code&gt; (GPU metrics)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NATS Exporter&lt;/strong&gt;: &lt;code&gt;http://localhost:7777/metrics&lt;/code&gt; (NATS messaging metrics)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. Configure Firewall for Metrics Collection
&lt;/h2&gt;

&lt;p&gt;Prometheus (running in Docker) scrapes metrics from worker endpoints running on the host machine. If a firewall is enabled, allow the worker and frontend ports for successful metrics collection.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Allow metrics ports through the firewall:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ sudo ufw allow 8000/tcp        &lt;span class="c"&gt;# Frontend API and metrics&lt;/span&gt;
$ sudo ufw allow 8081:8084/tcp   &lt;span class="c"&gt;# Worker metrics ports&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Verify the firewall rules:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ sudo ufw status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output displays the active firewall rules with allowed ports.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Verify CUDA Version and Pull Container Image
&lt;/h2&gt;

&lt;p&gt;The vLLM container requires a CUDA version match between the host driver and container runtime to prevent GPU kernel incompatibilities. The NVIDIA Container Toolkit maps host GPUs into containers, requiring the container's CUDA version to align with the host driver's supported version.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Check the installed CUDA version:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ nvidia-smi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output displays the CUDA version in the top-right corner of the table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 580.95.05              Driver Version: 580.95.05      CUDA Version: 13.0     |
+-----------------------------------------+------------------------+----------------------+
....
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Pull the vLLM container image from NGC. Match the CUDA version in the image tag to your system's CUDA version:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For CUDA 13.x, use:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ docker pull nvcr.io/nvidia/ai-dynamo/vllm-runtime:0.9.0-cuda13
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;For CUDA 12.x, use:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ docker pull nvcr.io/nvidia/ai-dynamo/vllm-runtime:0.9.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Visit the &lt;a href="https://catalog.ngc.nvidia.com/orgs/nvidia/teams/ai-dynamo/collections/ai-dynamo/artifacts" rel="noopener noreferrer"&gt;NVIDIA NGC Catalog&lt;/a&gt; to view all available image tags and CUDA versions.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This guide uses vLLM for examples, but observability features work with all supported backends (vLLM, SGLang, TensorRT-LLM). You can use the same observability settings with any backend by following the same configuration pattern.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  7. Configure Hugging Face Cache Permissions
&lt;/h2&gt;

&lt;p&gt;The container runs as UID 1000 and requires write access to the Hugging Face cache directory for model downloads. Incorrect permissions prevent the container from accessing cached model weights, causing worker initialization failures.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Create the cache directory if it does not exist:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ mkdir -p container/.cache/huggingface
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Set ownership to the container user (UID 1000):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ sudo chown -R 1000:1000 container/.cache/huggingface
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Set appropriate permissions:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ sudo chmod -R 775 container/.cache/huggingface
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  8. Configure Environment Variables for Observability
&lt;/h2&gt;

&lt;p&gt;NVIDIA Dynamo uses environment variables to control observability features across metrics, tracing, and logging systems. The following table describes the key environment variables for observability configuration.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Variable&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;th&gt;Default&lt;/th&gt;
&lt;th&gt;Impact&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;DYN_LOGGING_JSONL&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Enable structured JSONL logging with trace context&lt;/td&gt;
&lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Required for trace correlation in logs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;DYN_LOG&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Log level configuration (&lt;code&gt;error&lt;/code&gt;, &lt;code&gt;warn&lt;/code&gt;, &lt;code&gt;info&lt;/code&gt;, &lt;code&gt;debug&lt;/code&gt;, &lt;code&gt;trace&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;info&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Controls log verbosity&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;DYN_LOG_USE_LOCAL_TZ&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Use local timezone instead of UTC for log timestamps&lt;/td&gt;
&lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Timestamp formatting&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;OTEL_EXPORT_ENABLED&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Enable OTLP trace export to Tempo&lt;/td&gt;
&lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Required for trace visualization&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;OTEL_EXPORTER_OTLP_TRACES_ENDPOINT&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;OTLP gRPC endpoint for Tempo&lt;/td&gt;
&lt;td&gt;&lt;code&gt;http://localhost:4317&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Trace export destination&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;OTEL_SERVICE_NAME&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Service name for component identification in traces&lt;/td&gt;
&lt;td&gt;&lt;code&gt;dynamo&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Component labeling in traces&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;DYN_SYSTEM_PORT&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Backend worker system port for metrics and health checks&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;-1&lt;/code&gt; (disabled)&lt;/td&gt;
&lt;td&gt;Metrics endpoint port&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;DYN_HTTP_PORT&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Frontend HTTP port for API and metrics&lt;/td&gt;
&lt;td&gt;&lt;code&gt;8000&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Frontend metrics port&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  9. Setup Container and Observability Environment
&lt;/h2&gt;

&lt;p&gt;The container environment setup and observability configuration are common to both aggregated and disaggregated deployments. Complete these steps once before deploying either configuration.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Export your Hugging Face token to avoid rate limitations when downloading large models. Replace &lt;code&gt;YOUR_HF_TOKEN&lt;/code&gt; with your actual token:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;HF_TOKEN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;YOUR_HF_TOKEN
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Run the vLLM container with GPU access and workspace mounting. Use the image tag that matches your CUDA version from the previous section:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ ./container/run.sh -it --framework VLLM --mount-workspace --image nvcr.io/nvidia/ai-dynamo/vllm-runtime:0.9.0-cuda13 -e &lt;span class="nv"&gt;HF_TOKEN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$HF_TOKEN&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The command starts an interactive container session with GPU support and passes the Hugging Face token to the container.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Inside the container, create an observability environment configuration file:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ cat &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s1"&gt;'EOF'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; ~/observability.env
&lt;span class="c"&gt;# Logging Configuration&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;DYN_LOGGING_JSONL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;DYN_LOG&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;info

&lt;span class="c"&gt;# Tracing Configuration&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;OTEL_EXPORT_ENABLED&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;OTEL_EXPORTER_OTLP_TRACES_ENDPOINT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;http://localhost:4317
EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This environment file contains the observability configuration that will be sourced by both aggregated and disaggregated deployment scripts.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Deploy Aggregated Serving with Observability
&lt;/h2&gt;

&lt;p&gt;Aggregated serving runs both prefill and decode operations on a single worker, simplifying deployment while maintaining full observability capabilities. This configuration suits single-GPU setups or development environments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Create a launch script for aggregated serving with observability enabled:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ cat &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s1"&gt;'EOF'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; ~/aggregated_obs.sh
&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;

&lt;span class="nb"&gt;set&lt;/span&gt; -e
&lt;span class="nb"&gt;trap&lt;/span&gt; &lt;span class="s1"&gt;'echo Cleaning up...; kill 0'&lt;/span&gt; EXIT

&lt;span class="c"&gt;# Set deterministic hash for KV event IDs&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;PYTHONHASHSEED&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0

&lt;span class="c"&gt;# Model configuration - use command line argument or default&lt;/span&gt;
&lt;span class="nv"&gt;MODEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${1:-nvidia/Llama-3.1-Nemotron-Nano-4B-v1.1}"&lt;/span&gt;

&lt;span class="c"&gt;# Source observability environment variables&lt;/span&gt;
&lt;span class="nb"&gt;source&lt;/span&gt; ~/observability.env

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Starting Dynamo Frontend with observability..."&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;OTEL_SERVICE_NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;dynamo-frontend
&lt;span class="nv"&gt;DYN_HTTP_PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;${DYN_HTTP_PORT:-8000}&lt;/span&gt; python -m dynamo.frontend &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Starting vLLM Worker with model: $MODEL"&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;OTEL_SERVICE_NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;dynamo-worker-aggregated
&lt;span class="nv"&gt;DYN_SYSTEM_PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;${DYN_SYSTEM_PORT:-8081}&lt;/span&gt; \
    &lt;span class="nv"&gt;CUDA_VISIBLE_DEVICES&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0 python -m dynamo.vllm \
    --model &lt;span class="s2"&gt;"$MODEL"&lt;/span&gt; \
    --trust-remote-code \
    --enforce-eager \
    --connector none \
    --otlp-traces-endpoint=&lt;span class="s2"&gt;"$OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Waiting for services to initialize..."&lt;/span&gt;
sleep 30

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Aggregated deployment ready with observability enabled!"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Model: $MODEL"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"API Endpoint:"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  http://localhost:8000/v1/chat/completions"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Metrics Endpoints:"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  Frontend: http://localhost:8000/metrics"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  Worker: http://localhost:8081/metrics"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Observability UIs:"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  Grafana: http://localhost:3000 (username: dynamo, password: dynamo)"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  Prometheus: http://localhost:9090"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  Tempo: http://localhost:3200"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;

&lt;span class="c"&gt;# Keep script running&lt;/span&gt;
&lt;span class="nb"&gt;wait&lt;/span&gt;
EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The script configures the following observability components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Environment Variables&lt;/strong&gt;: Sources &lt;code&gt;observability.env&lt;/code&gt; to enable JSON logging (&lt;code&gt;DYN_LOGGING_JSONL=true&lt;/code&gt;) and OpenTelemetry trace export (&lt;code&gt;OTEL_EXPORT_ENABLED=true&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Service Names&lt;/strong&gt;: Sets a unique &lt;code&gt;OTEL_SERVICE_NAME&lt;/code&gt; for the frontend (&lt;code&gt;dynamo-frontend&lt;/code&gt;) and worker (&lt;code&gt;dynamo-worker-aggregated&lt;/code&gt;) to identify components in traces.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Metrics Endpoints&lt;/strong&gt;: Exposes metrics on port 8000 (frontend via &lt;code&gt;DYN_HTTP_PORT&lt;/code&gt;) and port 8081 (worker via &lt;code&gt;DYN_SYSTEM_PORT&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trace Export&lt;/strong&gt;: Configures the worker with &lt;code&gt;--otlp-traces-endpoint&lt;/code&gt; to send trace spans to Tempo at &lt;code&gt;http://localhost:4317&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Request Correlation&lt;/strong&gt;: Uses &lt;code&gt;PYTHONHASHSEED=0&lt;/code&gt; to ensure consistent KV event ID generation across requests for trace correlation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Make the script executable:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ chmod +x ~/aggregated_obs.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Run the deployment script:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ ~/aggregated_obs.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output displays initialization messages and endpoint URLs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Starting NVIDIA Dynamo Frontend with observability...
Starting Aggregated vLLM Worker with observability...
Waiting for services to initialize...
......
Aggregated deployment ready with observability enabled!
Model: nvidia/Llama-3.1-Nemotron-Nano-4B-v1.1

API Endpoint:
  http://localhost:8000/v1/chat/completions

Metrics Endpoints:
  Frontend: http://localhost:8000/metrics
  Worker: http://localhost:8081/metrics

Observability UIs:
  Grafana: http://localhost:3000 (username: dynamo, password: dynamo)
  Prometheus: http://localhost:9090
  Tempo: http://localhost:3200
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Open a new terminal session on your server (outside the container) and test with a chat completion request:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ curl -X POST http://localhost:8000/v1/chat/completions \
    -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
    -d &lt;span class="s1"&gt;'{
      "model": "nvidia/Llama-3.1-Nemotron-Nano-4B-v1.1",
      "messages": [{"role": "user", "content": "Hello! Tell me about AI."}],
      "max_tokens": 100
    }'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output displays the model's chat response in JSON format.&lt;/p&gt;

&lt;h3&gt;
  
  
  Verify Aggregated Deployment Observability
&lt;/h3&gt;

&lt;p&gt;Verification confirms that metrics, tracing, and logging systems are functioning correctly by checking endpoints and generating test requests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Verify metrics are exposed. Open a new terminal session:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ curl -s http://localhost:8000/metrics &lt;span class="o"&gt;|&lt;/span&gt; grep dynamo_frontend_requests_total
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output displays the frontend request counter metric:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight prometheus"&gt;&lt;code&gt;&lt;span class="c1"&gt;# HELP dynamo_frontend_requests_total Total number of LLM requests processed
# TYPE dynamo_frontend_requests_total counter
&lt;/span&gt;&lt;span class="na"&gt;dynamo_frontend_requests_total{endpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"chat_completions"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"nvidia/llama-3.1-nemotron-nano-4b-v1.1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;request_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"unary"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"success"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Verify worker metrics are exposed:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ curl -s http://localhost:8081/metrics &lt;span class="o"&gt;|&lt;/span&gt; grep dynamo_component_uptime_seconds
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output displays the worker uptime metric:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight prometheus"&gt;&lt;code&gt;&lt;span class="c1"&gt;# HELP dynamo_component_uptime_seconds Total uptime of the DistributedRuntime in seconds
# TYPE dynamo_component_uptime_seconds gauge
&lt;/span&gt;&lt;span class="n"&gt;dynamo_component_uptime_seconds&lt;/span&gt; &lt;span class="mf"&gt;234.966756758&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Send a test inference request with a custom request ID for trace correlation:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ curl -X POST http://localhost:8000/v1/chat/completions \
-H &lt;span class="s1"&gt;'Content-Type: application/json'&lt;/span&gt; \
-H &lt;span class="s1"&gt;'x-request-id: test-aggregated-001'&lt;/span&gt; \
-d &lt;span class="s1"&gt;'{
  "model": "nvidia/Llama-3.1-Nemotron-Nano-4B-v1.1",
  "max_completion_tokens": 50,
  "messages": [
    {"role": "user", "content": "Explain what observability means in distributed systems."}
  ]
}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output returns the generated response.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Check updated metrics after the request:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ curl -s http://localhost:8000/metrics &lt;span class="o"&gt;|&lt;/span&gt; grep dynamo_frontend_requests_total
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The counter increments to reflect the processed request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight prometheus"&gt;&lt;code&gt;&lt;span class="na"&gt;dynamo_frontend_requests_total{endpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"chat_completions"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"nvidia/llama-3.1-nemotron-nano-4b-v1.1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;request_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"unary"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"success"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  View Traces in Tempo
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Access Grafana to view the trace. Open &lt;code&gt;http://SERVER-IP:3000&lt;/code&gt; in a web browser and log in with username &lt;code&gt;dynamo&lt;/code&gt; and password &lt;code&gt;dynamo&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Navigate to &lt;strong&gt;Explore&lt;/strong&gt; (compass icon in the left sidebar).&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Tempo&lt;/strong&gt; as the data source (should be selected by default).&lt;/li&gt;
&lt;li&gt;In the query type selector, choose &lt;strong&gt;Search&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Use the Search tab to find traces by configuring the following options:

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Service Name&lt;/strong&gt;: Select a service (e.g., &lt;code&gt;dynamo-frontend&lt;/code&gt;, &lt;code&gt;dynamo-worker-aggregated&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Span Name&lt;/strong&gt;: Select a span (e.g., &lt;code&gt;http-request&lt;/code&gt;, &lt;code&gt;handle_payload&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tags&lt;/strong&gt;: Add tag &lt;code&gt;x_request_id&lt;/code&gt; with value &lt;code&gt;test-aggregated-001&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Run query&lt;/strong&gt; to execute the search.&lt;/li&gt;
&lt;li&gt;Click on the displayed trace to view the detailed flame graph showing the request flow through the frontend and worker components, including timing information for each span.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  View Aggregated Metrics Dashboard
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Navigate to &lt;strong&gt;Dashboards&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click on &lt;strong&gt;Dynamo Dashboard&lt;/strong&gt; to open the main metrics dashboard. The dashboard displays real-time metrics including:

&lt;ul&gt;
&lt;li&gt;Frontend request rate and latency&lt;/li&gt;
&lt;li&gt;Worker token generation throughput&lt;/li&gt;
&lt;li&gt;KV cache statistics (active blocks, total blocks, GPU cache usage)&lt;/li&gt;
&lt;li&gt;Component uptime and health status&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Use the time range selector in the top-right corner to adjust the viewing window (Last 5 minutes, Last 15 minutes, etc.).&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  11. Deploy Disaggregated Serving with Observability
&lt;/h2&gt;

&lt;p&gt;Disaggregated serving separates prefill and decode operations across different workers, enabling independent scaling and optimization of each phase. This configuration requires multiple GPUs and provides detailed observability into each pipeline stage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Create the disaggregated deployment script:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ cat &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s1"&gt;'EOF'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; ~/disaggregated_obs.sh
&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;

&lt;span class="c"&gt;# Source observability environment variables&lt;/span&gt;
&lt;span class="nb"&gt;source&lt;/span&gt; ~/observability.env

&lt;span class="c"&gt;# Kill any existing Dynamo processes&lt;/span&gt;
pkill -f &lt;span class="s2"&gt;"dynamo.frontend"&lt;/span&gt;
pkill -f &lt;span class="s2"&gt;"dynamo.vllm"&lt;/span&gt;
sleep 2

&lt;span class="c"&gt;# Set deterministic hash for KV event IDs&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;PYTHONHASHSEED&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0

&lt;span class="c"&gt;# Model configuration - use command line argument or default&lt;/span&gt;
&lt;span class="nv"&gt;MODEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${1:-nvidia/Llama-3.1-Nemotron-Nano-4B-v1.1}"&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Starting NVIDIA Dynamo Frontend with observability..."&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;OTEL_SERVICE_NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;dynamo-frontend
&lt;span class="nv"&gt;DYN_HTTP_PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;${DYN_HTTP_PORT:-8000}&lt;/span&gt; python -m dynamo.frontend &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Starting Decode Workers with observability..."&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Model: $MODEL"&lt;/span&gt;

&lt;span class="c"&gt;# Decode Worker 1 - GPU 0&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;OTEL_SERVICE_NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;dynamo-worker-decode-1
&lt;span class="nv"&gt;DYN_SYSTEM_PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;${DYN_SYSTEM_PORT:-8081}&lt;/span&gt; \
&lt;span class="nv"&gt;CUDA_VISIBLE_DEVICES&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0 python -m dynamo.vllm \
    --model &lt;span class="s2"&gt;"$MODEL"&lt;/span&gt; \
    --trust-remote-code \
    --is-decode-worker \
    --max-model-len 2048 \
    --otlp-traces-endpoint=&lt;span class="s2"&gt;"$OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;

&lt;span class="c"&gt;# Decode Worker 2 - GPU 1&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;OTEL_SERVICE_NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;dynamo-worker-decode-2
&lt;span class="nv"&gt;DYN_SYSTEM_PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;8082 \
&lt;span class="nv"&gt;VLLM_NIXL_SIDE_CHANNEL_PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;20097 \
&lt;span class="nv"&gt;CUDA_VISIBLE_DEVICES&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1 python -m dynamo.vllm \
    --model &lt;span class="s2"&gt;"$MODEL"&lt;/span&gt; \
    --trust-remote-code \
    --is-decode-worker \
    --max-model-len 2048 \
    --otlp-traces-endpoint=&lt;span class="s2"&gt;"$OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Starting Prefill Workers with observability..."&lt;/span&gt;
&lt;span class="c"&gt;# Prefill Worker 1 - GPU 2&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;OTEL_SERVICE_NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;dynamo-worker-prefill-1
&lt;span class="nv"&gt;DYN_SYSTEM_PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;8083 \
&lt;span class="nv"&gt;DYN_VLLM_KV_EVENT_PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;20082 \
&lt;span class="nv"&gt;CUDA_VISIBLE_DEVICES&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;2 python -m dynamo.vllm \
    --model &lt;span class="s2"&gt;"$MODEL"&lt;/span&gt; \
    --trust-remote-code \
    --is-prefill-worker \
    --max-model-len 2048 \
    --otlp-traces-endpoint=&lt;span class="s2"&gt;"$OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"&lt;/span&gt; \
    --kv-events-config &lt;span class="s1"&gt;'{"publisher":"zmq","topic":"kv-events","endpoint":"tcp://*:20082","enable_kv_cache_events":true}'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;

&lt;span class="c"&gt;# Prefill Worker 2 - GPU 3&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;OTEL_SERVICE_NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;dynamo-worker-prefill-2
&lt;span class="nv"&gt;DYN_SYSTEM_PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;8084 \
&lt;span class="nv"&gt;DYN_VLLM_KV_EVENT_PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;20083 \
&lt;span class="nv"&gt;VLLM_NIXL_SIDE_CHANNEL_PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;20099 \
&lt;span class="nv"&gt;CUDA_VISIBLE_DEVICES&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;3 python -m dynamo.vllm \
    --model &lt;span class="s2"&gt;"$MODEL"&lt;/span&gt; \
    --trust-remote-code \
    --is-prefill-worker \
    --max-model-len 2048 \
    --otlp-traces-endpoint=&lt;span class="s2"&gt;"$OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"&lt;/span&gt; \
    --kv-events-config &lt;span class="s1"&gt;'{"publisher":"zmq","topic":"kv-events","endpoint":"tcp://*:20083","enable_kv_cache_events":true}'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Waiting for services to initialize..."&lt;/span&gt;
sleep 30

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Disaggregated deployment ready with observability enabled!"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Model: $MODEL"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"API Endpoint:"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  http://localhost:8000/v1/chat/completions"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Metrics Endpoints:"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  Frontend: http://localhost:8000/metrics"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  Decode Worker 1: http://localhost:8081/metrics"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  Decode Worker 2: http://localhost:8082/metrics"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  Prefill Worker 1: http://localhost:8083/metrics"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  Prefill Worker 2: http://localhost:8084/metrics"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Observability UIs:"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  Grafana: http://localhost:3000 (username: dynamo, password: dynamo)"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  Prometheus: http://localhost:9090"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  Tempo: http://localhost:3200"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;

&lt;span class="c"&gt;# Keep script running&lt;/span&gt;
&lt;span class="nb"&gt;wait&lt;/span&gt;
EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The script configures disaggregated observability with the following components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Service Separation&lt;/strong&gt;: Deploys 4 workers with unique &lt;code&gt;OTEL_SERVICE_NAME&lt;/code&gt; identifiers (&lt;code&gt;dynamo-worker-decode-1&lt;/code&gt;, &lt;code&gt;dynamo-worker-decode-2&lt;/code&gt;, &lt;code&gt;dynamo-worker-prefill-1&lt;/code&gt;, &lt;code&gt;dynamo-worker-prefill-2&lt;/code&gt;) for trace differentiation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GPU Allocation&lt;/strong&gt;: Assigns workers to specific GPUs using &lt;code&gt;CUDA_VISIBLE_DEVICES&lt;/code&gt; (decode workers on GPUs 0-1, prefill workers on GPUs 2-3).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Metrics Endpoints&lt;/strong&gt;: Exposes metrics on separate ports for each worker (&lt;code&gt;DYN_SYSTEM_PORT=8081-8084&lt;/code&gt;) to enable per-worker monitoring.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trace Export&lt;/strong&gt;: Configures all workers with &lt;code&gt;--otlp-traces-endpoint&lt;/code&gt; to send trace spans to Tempo, enabling end-to-end request flow visualization across prefill and decode stages.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;KV Cache Events&lt;/strong&gt;: Enables KV cache event publishing on prefill workers using &lt;code&gt;--kv-events-config&lt;/code&gt; with ZMQ endpoints (ports 20082-20083) for router optimization.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NIXL Communication&lt;/strong&gt;: Configures side channel ports (&lt;code&gt;VLLM_NIXL_SIDE_CHANNEL_PORT&lt;/code&gt;) for inter-worker KV cache transfer between prefill and decode workers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Make the script executable:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ chmod +x ~/disaggregated_obs.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Run the deployment script:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ ~/disaggregated_obs.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output displays initialization messages and endpoint URLs for all components:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Starting NVIDIA Dynamo Frontend with observability...
Starting Decode Workers with observability...
Starting Prefill Workers with observability...
Waiting for services to initialize...

Disaggregated deployment ready with observability enabled!

API Endpoint:
  http://localhost:8000/v1/chat/completions

Metrics Endpoints:
  Frontend: http://localhost:8000/metrics
  Decode Worker 1: http://localhost:8081/metrics
  Decode Worker 2: http://localhost:8082/metrics
  Prefill Worker 1: http://localhost:8083/metrics
  Prefill Worker 2: http://localhost:8084/metrics

Observability UIs:
  Grafana: http://localhost:3000 (username: dynamo, password: dynamo)
  Prometheus: http://localhost:9090
  Tempo: http://localhost:3200
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Verify Disaggregated Deployment Observability
&lt;/h3&gt;

&lt;p&gt;Verification confirms that all workers expose metrics independently and traces capture the full request flow across prefill and decode stages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Verify all worker metrics endpoints are accessible. Open a new terminal session:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="k"&gt;for&lt;/span&gt; port &lt;span class="k"&gt;in&lt;/span&gt; 8081 8082 8083 8084&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Port $port ==="&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; curl -s http://localhost:&lt;span class="nv"&gt;$port&lt;/span&gt;/metrics &lt;span class="o"&gt;|&lt;/span&gt; head -5&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output displays metrics from each worker.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Send a test inference request with a custom request ID:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ curl -X POST http://localhost:8000/v1/chat/completions \
-H &lt;span class="s1"&gt;'Content-Type: application/json'&lt;/span&gt; \
-H &lt;span class="s1"&gt;'x-request-id: test-disaggregated-001'&lt;/span&gt; \
-d &lt;span class="s1"&gt;'{
  "model": "nvidia/Llama-3.1-Nemotron-Nano-4B-v1.1",
  "max_completion_tokens": 100,
  "messages": [
    {"role": "user", "content": "Describe the benefits of disaggregated serving in LLM inference."}
  ]
}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output returns the generated response after processing through separate prefill and decode workers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Check KV computed tokens statistics from a prefill worker:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ curl -s http://localhost:8083/metrics &lt;span class="o"&gt;|&lt;/span&gt; grep request_prefill_kv_computed_tokens_created
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output displays KV cache metrics including active blocks, total blocks, and cache usage percentage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight prometheus"&gt;&lt;code&gt;&lt;span class="c1"&gt;# HELP vllm:request_prefill_kv_computed_tokens_created Histogram of new KV tokens computed during prefill (excluding cached tokens).
# TYPE vllm:request_prefill_kv_computed_tokens_created gauge
&lt;/span&gt;&lt;span class="na"&gt;vllm:request_prefill_kv_computed_tokens_created{engine&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;model_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"nvidia/Llama-3.1-Nemotron-Nano-4B-v1.1"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="mf"&gt;1.7725614597782164e+09&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  View Traces in Tempo
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Access Grafana at &lt;code&gt;http://SERVER-IP:3000&lt;/code&gt; and navigate to &lt;strong&gt;Explore&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Tempo&lt;/strong&gt; as the data source.&lt;/li&gt;
&lt;li&gt;In the query type selector, choose &lt;strong&gt;Search&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Use the Search tab to find traces by configuring the following options:

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Service Name&lt;/strong&gt;: Select a service (e.g., &lt;code&gt;dynamo-frontend&lt;/code&gt;, &lt;code&gt;dynamo-worker-prefill-1&lt;/code&gt;, &lt;code&gt;dynamo-worker-decode-1&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Span Name&lt;/strong&gt;: Select a span (e.g., &lt;code&gt;http-request&lt;/code&gt;, &lt;code&gt;prefill_routing&lt;/code&gt;, &lt;code&gt;handle_payload&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tags&lt;/strong&gt;: Add tag &lt;code&gt;x_request_id&lt;/code&gt; with value &lt;code&gt;test-disaggregated-001&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Run query&lt;/strong&gt; to execute the search.&lt;/li&gt;
&lt;li&gt;Click on the displayed trace to view the detailed flame graph. Verify the trace includes separate spans for:

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;http-request&lt;/strong&gt; (frontend root span)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;prefill_routing&lt;/strong&gt; (frontend routing span)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;handle_payload&lt;/strong&gt; (prefill worker span)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;handle_payload&lt;/strong&gt; (decode worker span)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The span hierarchy displays the request flow from the frontend through prefill to decode operations with timing information for each pipeline stage.&lt;/p&gt;

&lt;h4&gt;
  
  
  View Disaggregated Metrics Dashboard
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Navigate to &lt;strong&gt;Dashboards&lt;/strong&gt; (four squares icon in the left sidebar).&lt;/li&gt;
&lt;li&gt;Click on &lt;strong&gt;Dynamo Dashboard&lt;/strong&gt; to open the main metrics dashboard. It displays real-time metrics from all workers including:

&lt;ul&gt;
&lt;li&gt;Frontend request rate and latency&lt;/li&gt;
&lt;li&gt;Per-worker token generation throughput (decode and prefill workers)&lt;/li&gt;
&lt;li&gt;KV cache statistics across all workers&lt;/li&gt;
&lt;li&gt;Disaggregated request flow metrics&lt;/li&gt;
&lt;li&gt;Component uptime and health status&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Use the time range selector in the top-right corner to adjust the viewing window and observe metrics from different workers.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Build Grafana alerting rules on top of the &lt;code&gt;dynamo_*&lt;/code&gt; Prometheus metrics for TTFT and token throughput regressions.&lt;/li&gt;
&lt;li&gt;Extend trace retention in Tempo for longer-term performance analysis.&lt;/li&gt;
&lt;li&gt;Apply the same observability pattern to SGLang or TensorRT-LLM backends.&lt;/li&gt;
&lt;li&gt;Wire the OTLP endpoint to an external observability backend for multi-cluster visibility.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the full guide with additional tips, visit the original article on &lt;strong&gt;&lt;a href="https://docs.vultr.com/how-to-enable-observability-in-nvidia-dynamo-inference-pipelines" rel="noopener noreferrer"&gt;Vultr Docs&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>nvidia</category>
      <category>llm</category>
      <category>observability</category>
      <category>prometheus</category>
    </item>
    <item>
      <title>Creating and Using Bash Alias</title>
      <dc:creator>Sanskriti Harmukh</dc:creator>
      <pubDate>Fri, 20 Nov 2026 01:24:51 +0000</pubDate>
      <link>https://dev.to/vultr/creating-and-using-bash-alias-2md4</link>
      <guid>https://dev.to/vultr/creating-and-using-bash-alias-2md4</guid>
      <description>&lt;p&gt;A Bash alias is a shortcut for substituting long commands with shorter commands to save time and avoid repetitive typing. In a shell environment, you should store Bash aliases in the &lt;code&gt;.bashrc&lt;/code&gt; file under the user's home directory. This guide covers the Bash alias syntax, how to create temporary and permanent aliases, and how to use aliases with functions, arguments, and conditional logic inside scripts. By the end, you'll have reusable aliases loaded automatically in every new shell session.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. The Bash Alias Syntax
&lt;/h2&gt;

&lt;p&gt;The following is a basic Bash alias syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;alias&lt;/span&gt; alias-name=&lt;span class="s2"&gt;"command"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above command:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;alias&lt;/code&gt;: Creates a new alias command.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;alias-name&lt;/code&gt;: Specifies the alias name.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;command&lt;/code&gt;: Sets the command that you want to substitute. Enclose the command using single or double quotes if the command includes spaces or special characters to prevent shell interpretation.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Create Bash Aliases
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Create a sample alias application, such as &lt;code&gt;hello-world&lt;/code&gt;, that runs the &lt;code&gt;echo&lt;/code&gt; command:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="nb"&gt;alias&lt;/span&gt; hello-world=&lt;span class="s1"&gt;'echo "Hello, World!"'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Run the &lt;code&gt;hello-world&lt;/code&gt; command to display the result:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ hello-world
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello, World!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Create another &lt;code&gt;list-files&lt;/code&gt; alias to substitute the &lt;code&gt;ls&lt;/code&gt; command:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="nb"&gt;alias&lt;/span&gt; list-files=&lt;span class="s1"&gt;'ls'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Run the &lt;code&gt;list-files&lt;/code&gt; command:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ list-files
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify that the command lists all files in your working directory.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create Permanent Bash Aliases
&lt;/h3&gt;

&lt;p&gt;Bash aliases are temporary in a shell environment unless you save them in the &lt;code&gt;.bashrc&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Switch to your user's home directory:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="nb"&gt;cd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Create a new &lt;code&gt;myaliases&lt;/code&gt; file using a text editor like &lt;code&gt;nano&lt;/code&gt;:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ nano myaliases
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Add the following directives to the &lt;code&gt;myaliases&lt;/code&gt; file:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;alias&lt;/span&gt; hello-world=&lt;span class="s1"&gt;'echo'&lt;/span&gt;
&lt;span class="nb"&gt;alias&lt;/span&gt; list-files=&lt;span class="s1"&gt;'ls'&lt;/span&gt;
&lt;span class="nb"&gt;alias&lt;/span&gt; &lt;span class="nv"&gt;newfile&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'touch'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save and close the file. The &lt;code&gt;hello-world&lt;/code&gt;, &lt;code&gt;list-files&lt;/code&gt;, and &lt;code&gt;newfile&lt;/code&gt; aliases in the above configuration execute the &lt;code&gt;echo&lt;/code&gt;, &lt;code&gt;ls&lt;/code&gt;, and &lt;code&gt;touch&lt;/code&gt; commands respectively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Open the &lt;code&gt;.bashrc&lt;/code&gt; file:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ nano .bashrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Add the following directives at the end of the file:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; -f myaliases &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
. myaliases
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save and close the file. The above &lt;code&gt;if-then&lt;/code&gt; statement finds the &lt;code&gt;myaliases&lt;/code&gt; file in the user's home directory and runs it to load all aliases in the &lt;code&gt;.bashrc&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Apply the &lt;code&gt;.bashrc&lt;/code&gt; changes to your shell environment:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="nb"&gt;source&lt;/span&gt; .bashrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;7. Run the &lt;code&gt;newfile&lt;/code&gt; alias command and specify &lt;code&gt;sample-file&lt;/code&gt; as an argument to create a new file:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ newfile sample-file
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;8. List files using the &lt;code&gt;list-files&lt;/code&gt; alias in your working directory and verify that &lt;code&gt;sample-file&lt;/code&gt; is available:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ list-files
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;... sample-file ....
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;9. Run the &lt;code&gt;hello-world&lt;/code&gt; alias and specify &lt;code&gt;Greetings from the team&lt;/code&gt; as an option:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ hello-world Greetings from the team
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Greetings from the team
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Use Bash Aliases with Functions and Arguments
&lt;/h2&gt;

&lt;p&gt;You can combine aliases with command arguments and functions in Bash scripts to perform specific tasks, such as creating and managing files.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Create a new &lt;code&gt;bashalias.sh&lt;/code&gt; script:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ nano bashalias.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Add the following contents to the &lt;code&gt;bashalias.sh&lt;/code&gt; file:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;

myfunction &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;{&lt;/span&gt;
mkdir -p &lt;span class="s2"&gt;"$1"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd&lt;/span&gt; &lt;span class="s2"&gt;"$1"&lt;/span&gt;
touch hello_bash
&lt;span class="o"&gt;}&lt;/span&gt;

myfunction &lt;span class="nv"&gt;$1&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"New Directory and File Created."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save and close the file. In the above script, the &lt;code&gt;myfunction&lt;/code&gt; function works as an alias for the &lt;code&gt;mkdir&lt;/code&gt;, &lt;code&gt;cd&lt;/code&gt;, and &lt;code&gt;touch&lt;/code&gt; commands to create a new directory. The function then switches to the directory and creates a new &lt;code&gt;hello_bash&lt;/code&gt; file. You can convert &lt;code&gt;myfunction&lt;/code&gt; to a global alias command by appending it to the &lt;code&gt;.bashrc&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Run the script using Bash and specify &lt;code&gt;test_directory&lt;/code&gt; as the command option:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ bash bashalias.sh test_directory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. List the files in the &lt;code&gt;test_directory&lt;/code&gt;:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ ls test_directory/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;hello_bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Use Bash Alias in Bash Script
&lt;/h2&gt;

&lt;p&gt;You can use Bash aliases in scripts to shorten long commands and allow code reusability with other Bash features such as conditional statements and loops.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Create a new &lt;code&gt;advanced-alias.sh&lt;/code&gt; script:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ nano advanced-alias.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Add the following contents to the &lt;code&gt;advanced-alias.sh&lt;/code&gt; file:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;

&lt;span class="nb"&gt;shopt&lt;/span&gt; -s expand_aliases

&lt;span class="nb"&gt;alias&lt;/span&gt; &lt;span class="nv"&gt;sysinfo&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'uname -a &amp;amp;&amp;amp; lscpu &amp;amp;&amp;amp; free -h'&lt;/span&gt;
&lt;span class="nb"&gt;alias&lt;/span&gt; &lt;span class="nv"&gt;lamp&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'sudo apt update &amp;amp;&amp;amp; sudo apt install apache mysql php'&lt;/span&gt;
&lt;span class="nb"&gt;alias&lt;/span&gt; &lt;span class="nv"&gt;lemp&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'sudo apt update &amp;amp;&amp;amp; sudo apt install nginx mysql php'&lt;/span&gt;
&lt;span class="nb"&gt;alias&lt;/span&gt; &lt;span class="nv"&gt;mean&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'sudo apt update &amp;amp;&amp;amp; sudo apt install -y mongodb npm &amp;amp;&amp;amp; sudo npm install -g @angular/cli &amp;amp;&amp;amp; sudo npm'&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Select an option:"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"1. Show System Information"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"2. Install LAMP"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"3. Install LEMP"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"4. Install MEAN"&lt;/span&gt;
&lt;span class="nb"&gt;read&lt;/span&gt; -p &lt;span class="s2"&gt;"Enter your selection (1-4): "&lt;/span&gt; selection

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$selection"&lt;/span&gt; -eq 1 &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; -e &lt;span class="s2"&gt;"\nGathering system information..."&lt;/span&gt;
    sysinfo

&lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$selection"&lt;/span&gt; -eq 2 &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; -e &lt;span class="s2"&gt;"\n Installing the LAMP Stack"&lt;/span&gt;
    lamp

&lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$selection"&lt;/span&gt; -eq 3 &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; -e &lt;span class="s2"&gt;"\n Installing LEMP"&lt;/span&gt;
    lemp

&lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$selection"&lt;/span&gt; -eq 4 &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; -e &lt;span class="s2"&gt;"\nInstalling MEAN:"&lt;/span&gt;
    mean

&lt;span class="k"&gt;else&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Invalid selection. Please select a valid option."&lt;/span&gt;
    &lt;span class="nb"&gt;exit&lt;/span&gt; 1
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save and close the file. The &lt;code&gt;shopt -s expand_aliases&lt;/code&gt; command in the above script enables alias expansion while the &lt;code&gt;lamp&lt;/code&gt;, &lt;code&gt;lemp&lt;/code&gt;, and &lt;code&gt;mean&lt;/code&gt; Bash aliases shorten the full installation commands to install specific applications. The &lt;code&gt;selection&lt;/code&gt; variable stores the user input and uses the &lt;code&gt;if-elif&lt;/code&gt; conditional statement to run the Bash alias commands.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Run the script using Bash:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ bash advanced-alias.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Enter a selection such as &lt;code&gt;2&lt;/code&gt; to run the &lt;code&gt;lamp&lt;/code&gt; alias command:&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;Select an option:
1. Show System Information
2. Install LAMP
3. Install LEMP
4. Install MEAN
Enter your selection (1-4): 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Installing the LAMP Stack
.................................
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Organize related aliases into separate files and source them conditionally for different projects.&lt;/li&gt;
&lt;li&gt;Share a team-wide aliases file via a dotfiles repo for consistent shortcuts across machines.&lt;/li&gt;
&lt;li&gt;Combine aliases with Bash functions for more complex argument handling.&lt;/li&gt;
&lt;li&gt;Explore &lt;code&gt;complete&lt;/code&gt; and &lt;code&gt;compgen&lt;/code&gt; to add tab-completion to custom aliases.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the full guide with additional tips, visit the original article on &lt;strong&gt;&lt;a href="https://docs.vultr.com/how-to-create-and-use-bash-alias" rel="noopener noreferrer"&gt;Vultr Docs&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>bash</category>
      <category>linux</category>
      <category>cli</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Creating Environment Variables in Linux</title>
      <dc:creator>Sanskriti Harmukh</dc:creator>
      <pubDate>Fri, 20 Nov 2026 01:24:05 +0000</pubDate>
      <link>https://dev.to/vultr/creating-environment-variables-in-linux-2dna</link>
      <guid>https://dev.to/vultr/creating-environment-variables-in-linux-2dna</guid>
      <description>&lt;p&gt;Environment variables let you control how software behaves without modifying the underlying code. Most Linux distributions include a set of predefined environment variables, and you can also define custom variables to store config data, control application behavior, or share values between processes and shell scripts. This guide covers how to view, create, modify, and delete environment variables in Linux, make them persistent across sessions, define global variables for all users, and use them inside shell scripts. By the end, you'll have temporary, persistent, and global environment variables set up and referenced from a working Bash script.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. View Available Environment Variables
&lt;/h2&gt;

&lt;p&gt;Linux systems come with several predefined environment variables such as &lt;code&gt;HOME&lt;/code&gt;, &lt;code&gt;USER&lt;/code&gt;, &lt;code&gt;PWD&lt;/code&gt;, and &lt;code&gt;PATH&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. List all current environment variables:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ env
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;PWD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/home/user
&lt;span class="nv"&gt;HOME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/home/user
&lt;span class="nv"&gt;USER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;user
&lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also use the &lt;code&gt;printenv&lt;/code&gt; command to display all environment variables.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Print your current Linux username:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$USER&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. View an environment variable in key-value format using &lt;code&gt;grep&lt;/code&gt;:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ env &lt;span class="o"&gt;|&lt;/span&gt; grep &lt;span class="k"&gt;USER&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also use &lt;code&gt;printenv | grep USER&lt;/code&gt; to achieve the same result.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Create Temporary Environment Variables
&lt;/h2&gt;

&lt;p&gt;To define a temporary environment variable in Linux, write the variable name (key) in uppercase and assign it a string value. Temporary environment variables remain active only within the current terminal session and do not persist after you close the shell.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Define a new environment variable named &lt;code&gt;GREETING&lt;/code&gt;:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="nv"&gt;GREETING&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;Hello
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enclose the value in double quotes if it includes spaces, for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="nv"&gt;GREETING&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Hello World"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Export the variable so that child processes can access it:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="kd"&gt;export&lt;/span&gt; GREETING
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Verify that the variable is set:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$GREETING&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Temporary environment variables only last for the duration of the current shell session. Once you close the terminal, they're removed automatically.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Persist Environment Variables
&lt;/h2&gt;

&lt;p&gt;To retain environment variables across terminal sessions, define them in your shell's configuration file, such as &lt;code&gt;~/.bashrc&lt;/code&gt; or &lt;code&gt;~/.bash_profile&lt;/code&gt; if you're using the Bash shell. This ensures the variable loads every time you start a new session.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Open your &lt;code&gt;~/.bashrc&lt;/code&gt; file in a text editor:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ nano ~/.bashrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Add the following line to the bottom of the file:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;GREETING&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;Hello
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save and close the file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Reload the shell configuration to apply the changes:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="nb"&gt;source&lt;/span&gt; ~/.bashrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Confirm that the environment variable is now available:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$GREETING&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Open a new terminal window and verify the variable persists:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$GREETING&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Modify Environment Variables
&lt;/h2&gt;

&lt;p&gt;You can update environment variables either temporarily or permanently. Not all environment variables are intended to be changed — system-defined variables often control critical operations and should only be modified with caution. Always ensure you have the proper permissions and understand the implications before making changes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Update the &lt;code&gt;GREETING&lt;/code&gt; variable value in your current terminal session:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;GREETING&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;Hi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Confirm the new value:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$GREETING&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Open your shell configuration file to persist the change across sessions:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ nano ~/.bashrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Modify the value for the &lt;code&gt;GREETING&lt;/code&gt; definition:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;GREETING&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;Hi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Reload the file to apply the changes:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="nb"&gt;source&lt;/span&gt; ~/.bashrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Remove Environment Variables
&lt;/h2&gt;

&lt;p&gt;To remove an environment variable, use the &lt;code&gt;unset&lt;/code&gt; command. If you defined the variable in your shell configuration file, delete the definition there to prevent it from being reloaded in future sessions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Use &lt;code&gt;unset&lt;/code&gt; to remove the &lt;code&gt;GREETING&lt;/code&gt; environment variable:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="kd"&gt;unset&lt;/span&gt; GREETING
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Verify that the variable has been removed:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$GREETING&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If no output is returned, the variable has been successfully removed.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;unset&lt;/code&gt; only removes variables from the current session. If the variable is defined in your shell configuration file (such as &lt;code&gt;~/.bashrc&lt;/code&gt;), it will reappear in new sessions unless you also delete the definition from the file.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Create Global Environment Variables
&lt;/h2&gt;

&lt;p&gt;By default, environment variables apply only to the user who created them. If you want to define environment variables that are accessible system-wide, for all users and environments, add them to the &lt;code&gt;/etc/environment&lt;/code&gt; file. This file is parsed during login and is suitable for defining global values without shell-specific syntax.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Open the &lt;code&gt;/etc/environment&lt;/code&gt; file using Nano:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ sudo nano /etc/environment
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only users with root privileges can edit &lt;code&gt;/etc/environment&lt;/code&gt;, as changes affect all users system-wide. Avoid storing passwords or secrets in global variables, since they're readable by all users.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Add your variable without the &lt;code&gt;export&lt;/code&gt; keyword:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="nv"&gt;GLOBAL_GREETING&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;Hello
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Do not include &lt;code&gt;export&lt;/code&gt;. The &lt;a href="https://man7.org/linux/man-pages/man8/pam_env.8.html" rel="noopener noreferrer"&gt;pam_env module&lt;/a&gt;, which parses this file, does not support shell syntax or commands like &lt;code&gt;export&lt;/code&gt;. Save and close the file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Log out and log back in to reload the environment.&lt;/strong&gt; The system only reads &lt;code&gt;/etc/environment&lt;/code&gt; during the login process (via SSH, terminal, or GUI).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Run the &lt;code&gt;env&lt;/code&gt; command to confirm that the variable is available:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ env
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;GLOBAL_GREETING&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;Hello
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Create a new user:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ sudo adduser newuser
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6. Switch to the new user:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ su - newuser
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enter the password when prompted.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. Verify that the global environment variable is available to the new user:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$GLOBAL_GREETING&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;To remove the variable, delete its entry from &lt;code&gt;/etc/environment&lt;/code&gt; and log out and back in again.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Reference Environment Variables in a Bash Script
&lt;/h2&gt;

&lt;p&gt;You can dynamically reference environment variables — whether user-defined or global — inside Bash scripts. The steps below show how to use the global &lt;code&gt;GLOBAL_GREETING&lt;/code&gt; variable within a simple script.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Create a new script file named &lt;code&gt;greeting.sh&lt;/code&gt;:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ nano greeting.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Add the following script to reference the environment variable:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"${GLOBAL_GREETING}! Welcome to your server."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use curly braces (&lt;code&gt;{}&lt;/code&gt;) to clearly define the variable boundary when appending special characters or strings. For example, the exclamation mark (&lt;code&gt;!&lt;/code&gt;) follows the variable name without ambiguity. Save and close the file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Make the script executable:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ chmod +x greeting.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Run the script:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ ./greeting.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello! Welcome to your server.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also nest variables inside other variable assignments. For instance, &lt;code&gt;GREETING="Hi! $USER"&lt;/code&gt; expands &lt;code&gt;$USER&lt;/code&gt; when executed. However, this type of expansion only works when the variable is defined in a shell configuration file like &lt;code&gt;.bashrc&lt;/code&gt;, not in &lt;code&gt;/etc/environment&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Use environment variables to externalize secrets and config in your own scripts and services.&lt;/li&gt;
&lt;li&gt;Audit &lt;code&gt;/etc/environment&lt;/code&gt; and &lt;code&gt;.bashrc&lt;/code&gt; periodically to avoid variable sprawl.&lt;/li&gt;
&lt;li&gt;Combine environment variables with a &lt;code&gt;.env&lt;/code&gt; file and a loader for application-specific configuration.&lt;/li&gt;
&lt;li&gt;Explore &lt;code&gt;direnv&lt;/code&gt; for per-directory environment variable management.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the full guide with additional tips, visit the original article on &lt;strong&gt;&lt;a href="https://docs.vultr.com/how-to-create-environment-variables-in-linux" rel="noopener noreferrer"&gt;Vultr Docs&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>bash</category>
      <category>environmentvariables</category>
      <category>cli</category>
    </item>
    <item>
      <title>Building a Whisper.cpp Container Image</title>
      <dc:creator>Sanskriti Harmukh</dc:creator>
      <pubDate>Fri, 20 Nov 2026 01:23:40 +0000</pubDate>
      <link>https://dev.to/vultr/building-a-whispercpp-container-image-57jd</link>
      <guid>https://dev.to/vultr/building-a-whispercpp-container-image-57jd</guid>
      <description>&lt;p&gt;Whisper.cpp is a high-performance, lightweight inference implementation of OpenAI's Whisper automatic speech recognition (ASR) model. It's written in plain C/C++ with no external dependency packages, and it performs speech recognition with support for both CPU and GPU-based systems. This guide walks through cloning the Whisper.cpp repository and building container images for CPU-only and GPU-powered systems, then pushing the result to a container registry. By the end, you'll have a working Whisper.cpp container image tagged and pushed to a registry, ready to deploy.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before you begin:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Deploy a GPU-enabled server with NVIDIA GPU drivers, CUDA, and Docker preinstalled.&lt;/li&gt;
&lt;li&gt;Access the server using SSH.&lt;/li&gt;
&lt;li&gt;Start the Docker service.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ sudo systemctl start docker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Add the non-root user to the Docker group. For example, &lt;code&gt;linuxuser&lt;/code&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ sudo usermod -aG docker linuxuser
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Switch to the user:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ su - linuxuser
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Set Up the Server
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Create a new directory to store your Whisper C++ project files:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ mkdir whisper-project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Switch to the directory:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="nb"&gt;cd&lt;/span&gt; whisper-project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Clone the Whisper.cpp project repository using Git:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ git clone https://github.com/ggerganov/whisper.cpp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. List all directory files and verify that a new &lt;code&gt;whisper.cpp&lt;/code&gt; directory is available:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ ls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;whisper&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cpp&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Switch to the project directory:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="nb"&gt;cd&lt;/span&gt; whisper.cpp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6. List all hidden files and verify that a &lt;code&gt;.devops&lt;/code&gt; directory is available:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ ls -a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.  .devops         cmake           examples        ggml-backend.h       ggml-cuda     ggml-impl.h       ggml-metal.m      ggml-quants.c  ggml-vulkan.h    .gitmodules  models  .......
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;.devops&lt;/code&gt; directory includes the following Dockerfile resources:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;main.Dockerfile&lt;/code&gt;: Contains the build context for CPU systems.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;main-cuda.Dockerfile&lt;/code&gt;: Contains the build context for GPU systems.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use these resources in the next sections to build a CPU or GPU system container image.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Build a Whisper.cpp Container Image for CPU Systems
&lt;/h2&gt;

&lt;p&gt;Use &lt;code&gt;main.Dockerfile&lt;/code&gt;, which contains all necessary dependencies for CPU-based systems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Copy the &lt;code&gt;main.Dockerfile&lt;/code&gt; from the &lt;code&gt;.devops&lt;/code&gt; directory to the main &lt;code&gt;whisper.cpp&lt;/code&gt; project directory:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ cp .devops/main.Dockerfile .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Build a new container image using &lt;code&gt;main.Dockerfile&lt;/code&gt; with all files in the project directory. Replace &lt;code&gt;whisper-image&lt;/code&gt; with your desired image name:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ docker build -f main.Dockerfile -t whisper-image .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Wait for the build process to complete. When successful, your output should look like the one below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[+] Building 117.7s (12/12) FINISHED                                                                                                                                                                                 docker:default
 =&amp;gt; [internal] load build definition from main.Dockerfile                                                                                                                                                                      0.0s
 =&amp;gt; =&amp;gt; transferring dockerfile: 446B                                                                                                                                                                                           0.0s
 =&amp;gt; [internal] load metadata for docker.io/library/ubuntu:22.04                                                                                                                                                                3.1s
 =&amp;gt; [internal] load .dockerignore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. View all Docker images on the server and verify that the new &lt;code&gt;whisper-image&lt;/code&gt; is available:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ docker images
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;REPOSITORY      TAG       IMAGE ID       CREATED         SIZE
whisper-image   latest    d54bd7163db5   4 minutes ago   608MB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Build a Whisper.cpp Container Image for GPU Systems
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;main-cuda.Dockerfile&lt;/code&gt; resource contains the build context for GPU systems compatible with the latest NVIDIA CUDA drivers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Copy &lt;code&gt;main-cuda.Dockerfile&lt;/code&gt; to the main project directory:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ cp .devops/main-cuda.Dockerfile .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Build a new container image &lt;code&gt;whisper-gpu-image&lt;/code&gt; using the &lt;code&gt;main-cuda.Dockerfile&lt;/code&gt; with all files in the working project directory:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ docker build -f main-cuda.Dockerfile -t whisper-gpu-image .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. View all Docker images on the server and verify that the new Whisper.cpp GPU image is available:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ docker images
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;REPOSITORY          TAG       IMAGE ID       CREATED          SIZE
whisper-gpu-image   latest    47be5b1566fd   31 seconds ago   2.76GB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To run the Whisper.cpp GPU container image, verify that your target host includes the minimum or higher CUDA version referenced by the &lt;code&gt;ARG CUDA_VERSION=&lt;/code&gt; directive within &lt;code&gt;main-cuda.Dockerfile&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Verify the target CUDA version:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ cat main-cuda.Dockerfile &lt;span class="o"&gt;|&lt;/span&gt; grep &lt;span class="nv"&gt;CUDA_VERSION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;ARG&lt;/span&gt; &lt;span class="nv"&gt;CUDA_VERSION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;12.3.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Upload the Whisper.cpp Container Image to a Container Registry
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Open your cloud provider's console and navigate to your container registry to view the registry access credentials. Copy the Registry URL, Username, and API Key.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Switch to your server terminal session and log in to your container registry. Replace &lt;code&gt;your-registry.example.com&lt;/code&gt;, &lt;code&gt;exampleregistry&lt;/code&gt;, &lt;code&gt;exampleuser&lt;/code&gt;, &lt;code&gt;registry-password&lt;/code&gt; with your actual registry details:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ docker login https://your-registry.example.com/exampleregistry -u exampleuser -p registry-password
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Tag the Whisper.cpp container image with your desired registry tag. For example, &lt;code&gt;your-registry.example.com/exampleregistry/whisper-gpu-image&lt;/code&gt;:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ docker tag whisper-gpu-image your-registry.example.com/exampleregistry/whisper-gpu-image
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. View all Docker images on the server and verify that the new tagged image is available:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ docker images
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;REPOSITORY                                                     TAG       IMAGE ID       CREATED          SIZE
whisper-gpu-image                                              latest    47be5b1566fd   6 minutes ago    2.76GB
your-registry.example.com/exampleregistry/whisper-gpu-image    latest    47be5b1566fd   6 minutes ago    2.76GB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Push the tagged image to your container registry:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ docker push your-registry.example.com/exampleregistry/whisper-gpu-image
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When successful, your output should be similar to the one below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The push refers to repository [your-registry.example.com/exampleregistry/whisper-gpu-image]
a42c530a140b: Pushed
445c20a8fa7a: Pushed
8ceb9643fb36: Pushed
latest: digest: sha256:70645eed0095268b6c11b051083cb83c41c1991dc088b0d0485ccc50aa4cf4af size: 2838
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6. Open your container registry's management panel and verify that the new repository is available.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Push the image to a container registry and wire it into your transcription pipeline.&lt;/li&gt;
&lt;li&gt;Benchmark CPU vs. GPU inference latency for your target audio workloads.&lt;/li&gt;
&lt;li&gt;Automate rebuilds via CI so new whisper.cpp releases stay current.&lt;/li&gt;
&lt;li&gt;Experiment with different Whisper model sizes for accuracy/speed tradeoffs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the full guide with additional tips, visit the original article on &lt;strong&gt;&lt;a href="https://docs.vultr.com/how-to-build-a-whisper-cpp-container-image" rel="noopener noreferrer"&gt;Vultr Docs&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>whispercpp</category>
      <category>speechtotext</category>
      <category>ai</category>
    </item>
    <item>
      <title>Building a vLLM Container Image</title>
      <dc:creator>Sanskriti Harmukh</dc:creator>
      <pubDate>Fri, 20 Nov 2026 01:23:10 +0000</pubDate>
      <link>https://dev.to/vultr/building-a-vllm-container-image-1nif</link>
      <guid>https://dev.to/vultr/building-a-vllm-container-image-1nif</guid>
      <description>&lt;p&gt;vLLM is a fast inference and serving library for Large Language Models (LLMs). It offers integration with popular Hugging Face models, optimized CUDA kernels for NVIDIA GPUs, tensor parallelism support, and fast model execution. This guide walks through cloning the vLLM project repository and building container images for both CPU-only and GPU-powered systems, then pushing the result to a container registry. By the end, you'll have a working vLLM container image tagged and pushed to a registry, ready to deploy.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before you begin:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Deploy a GPU-enabled server with NVIDIA GPU drivers, CUDA, and Docker preinstalled.&lt;/li&gt;
&lt;li&gt;Access the server using SSH.&lt;/li&gt;
&lt;li&gt;Start the Docker service.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;1. Start the Docker service:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ sudo systemctl start docker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Set Up the Server
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Create a new directory to store your vLLM project files:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ mkdir vllm-project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Switch to the directory:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="nb"&gt;cd&lt;/span&gt; vllm-project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Clone the vLLM project repository using Git:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ git clone https://github.com/vllm-project/vllm/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. List files and verify that a new &lt;code&gt;vllm&lt;/code&gt; directory is available:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ ls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Switch to the &lt;code&gt;vllm&lt;/code&gt; project directory:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ &lt;span class="nb"&gt;cd&lt;/span&gt; vllm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6. List the directory files and verify that the necessary Dockerfile resources are available:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ ls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;benchmarks      collect_env.py   Dockerfile       docs       LICENSE                 pyproject.toml          requirements-common.txt  requirements-dev.txt     rocm_patch  vllm
cmake           CONTRIBUTING.md  Dockerfile.cpu   examples   MANIFEST.in             README.md               requirements-cpu.txt     requirements-neuron.txt  setup.py
CMakeLists.txt  csrc             Dockerfile.rocm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The vLLM project directory includes the following Dockerfile resources:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Dockerfile&lt;/code&gt;: Contains the main vLLM library build context with support for NVIDIA GPU systems.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Dockerfile.cpu&lt;/code&gt;: Contains the vLLM build context for CPU systems.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Dockerfile.rocm&lt;/code&gt;: Contains the build context for AMD GPU systems.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use these resources in the next sections to build a CPU or GPU system container image.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Build a vLLM Container Image for CPU Systems
&lt;/h2&gt;

&lt;p&gt;Use &lt;code&gt;Dockerfile.cpu&lt;/code&gt;, which contains the build context with all necessary packages and dependencies for CPU-based systems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Build a new container image using &lt;code&gt;Dockerfile.cpu&lt;/code&gt; with all files in the project working directory. Replace &lt;code&gt;vllm-image&lt;/code&gt; with your desired image name:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ docker build -f Dockerfile.cpu -t vllm-image .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. View all Docker images on the server and verify that your new vLLM image is available:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ docker images
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;REPOSITORY   TAG       IMAGE ID       CREATED              SIZE
vllm-image   latest    70f07e7c923f   About a minute ago   3.22GB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Build a vLLM Container Image for GPU Systems
&lt;/h2&gt;

&lt;p&gt;The vLLM project directory contains two Dockerfile resources for building container images for GPU-powered systems. Use the main &lt;code&gt;Dockerfile&lt;/code&gt; resource to build a new container image for GPU systems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Build a new container image &lt;code&gt;vllm-gpu-image&lt;/code&gt; using &lt;code&gt;Dockerfile&lt;/code&gt; with all files in the project directory:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ docker build -f Dockerfile -t vllm-gpu-image .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. View all Docker images on the server and verify that the new &lt;code&gt;vllm-gpu-image&lt;/code&gt; is available:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ docker images
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;REPOSITORY        TAG       IMAGE ID       CREATED       SIZE
vllm-gpu-image   latest    bf92416d18b4   8 hours ago   8.88GB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To run the vLLM GPU container image, verify that your target host runs the minimum or higher CUDA version referenced in the Dockerfile, and use the &lt;code&gt;--gpus all&lt;/code&gt; option when starting the container.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Verify the minimum CUDA version:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ cat Dockerfile &lt;span class="o"&gt;|&lt;/span&gt; grep &lt;span class="nv"&gt;CUDA_VERSION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;ARG&lt;/span&gt; &lt;span class="nv"&gt;CUDA_VERSION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;12.3.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Upload the vLLM Container Image to a Container Registry
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Open your cloud provider's console and navigate to your container registry to view the registry access credentials. Copy the Registry URL, Username, and API Key.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Switch to your server terminal session and log in to your container registry. Replace &lt;code&gt;your-registry.example.com&lt;/code&gt;, &lt;code&gt;exampleregistry&lt;/code&gt;, &lt;code&gt;exampleuser&lt;/code&gt;, &lt;code&gt;registry-password&lt;/code&gt; with your actual registry details:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ docker login https://your-registry.example.com/exampleregistry -u exampleuser -p registry-password
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Tag the vLLM container image with your desired registry tag. For example, &lt;code&gt;your-registry.example.com/exampleregistry/vllm-gpu-image&lt;/code&gt;:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ docker tag vllm-gpu-image your-registry.example.com/exampleregistry/vllm-gpu-image
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. View all Docker images on the server and verify that the new tagged image is available:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ docker images
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;REPOSITORY                                                TAG       IMAGE ID       CREATED       SIZE
vllm--gpu-image                                           latest    bf92416d18b4   8 hours ago   8.88GB
your-registry.example.com/exampleregistry/vllm-gpu-image  latest    bf92416d18b4   8 hours ago   8.88GB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Push the tagged image to your container registry:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ docker push your-registry.example.com/exampleregistry/vllm-gpu-image
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6. Open your container registry's management panel and verify that the new repository is available.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Reference the pushed image from your orchestrator (Docker Compose, Kubernetes, etc.) to deploy vLLM at scale.&lt;/li&gt;
&lt;li&gt;Benchmark inference throughput with vLLM's built-in benchmarking scripts before moving to production.&lt;/li&gt;
&lt;li&gt;Automate the build with a CI pipeline so new vLLM releases are rebuilt and republished automatically.&lt;/li&gt;
&lt;li&gt;Explore vLLM's tensor parallelism options for multi-GPU serving.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the full guide with additional tips, visit the original article on &lt;strong&gt;&lt;a href="https://docs.vultr.com/how-to-build-a-vllm-container-image" rel="noopener noreferrer"&gt;Vultr Docs&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>vllm</category>
      <category>llm</category>
      <category>containers</category>
    </item>
    <item>
      <title>Cleaning Up Docker with Prune</title>
      <dc:creator>Sanskriti Harmukh</dc:creator>
      <pubDate>Thu, 29 Oct 2026 17:09:11 +0000</pubDate>
      <link>https://dev.to/vultr/cleaning-up-docker-with-prune-1oll</link>
      <guid>https://dev.to/vultr/cleaning-up-docker-with-prune-1oll</guid>
      <description>&lt;p&gt;Docker is a widely used containerization platform for building, running, and distributing applications, but as you develop and deploy containers over time, it accumulates unused objects like stopped containers, dangling images, unused volumes, and networks. These leftover resources consume disk space and can degrade system performance if not cleaned up. This guide explains how to use the &lt;code&gt;docker prune&lt;/code&gt; command family to safely remove unused Docker resources, covering the differences between &lt;code&gt;docker prune&lt;/code&gt; and manual deletion, how to use each prune variant, and how to avoid accidental data loss during cleanup. By the end, you'll have a repeatable set of commands for keeping your Docker host's disk usage under control.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is docker prune?
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;docker prune&lt;/code&gt; command family removes unused Docker resources — stopped containers, dangling images, unused volumes, networks, and build cache — all in one go. It's faster and less manual than &lt;code&gt;docker rm&lt;/code&gt; or &lt;code&gt;docker rmi&lt;/code&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;
&lt;code&gt;docker rm&lt;/code&gt; / &lt;code&gt;rmi&lt;/code&gt;
&lt;/th&gt;
&lt;th&gt;&lt;code&gt;docker prune&lt;/code&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Removes one item at a time&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Removes all unused resources at once&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Requires specific names or IDs&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Safer for manual deletions&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Useful for quick cleanup&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Use &lt;code&gt;docker rm&lt;/code&gt; when you need precision, and &lt;code&gt;docker prune&lt;/code&gt; when you want to clean everything efficiently.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick Reference
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker system prune
&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker container prune
&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker image prune
&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker volume prune
&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker network prune
&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker builder prune
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Common Options for docker prune
&lt;/h2&gt;

&lt;p&gt;Most &lt;code&gt;docker prune&lt;/code&gt; commands support the following options:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--force&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Skip confirmation prompts. Use carefully to avoid accidental deletions.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--filter&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Filter resources by criteria such as age. Example: &lt;code&gt;--filter "until=24h"&lt;/code&gt; removes items older than 24 hours.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--all&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;(For images) Remove all unused images, not just dangling ones.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Use filters to avoid removing recently created resources during cleanup.&lt;/p&gt;

&lt;h2&gt;
  
  
  Clean All Docker Resources with docker system prune
&lt;/h2&gt;

&lt;p&gt;Removes all unused containers, networks, dangling images, and build cache. Syntax: &lt;code&gt;docker system prune [OPTIONS]&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Clean up all unused Docker resources interactively:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker system prune
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Clean up all unused resources without confirmation:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker system prune &lt;span class="nt"&gt;--force&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Clean up unused resources older than 48 hours:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker system prune &lt;span class="nt"&gt;--filter&lt;/span&gt; &lt;span class="s2"&gt;"until=48h"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;When to use:&lt;/strong&gt; after heavy development or container churn, when disk space is limited, or when no stopped containers or unused images are needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Clean Docker Containers with docker container prune
&lt;/h2&gt;

&lt;p&gt;Removes only stopped containers — running containers are not affected. Syntax: &lt;code&gt;docker container prune [OPTIONS]&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Remove all stopped containers:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker container prune
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Remove all stopped containers without confirmation:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker container prune &lt;span class="nt"&gt;--force&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Remove stopped containers older than 24 hours:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker container prune &lt;span class="nt"&gt;--filter&lt;/span&gt; &lt;span class="s2"&gt;"until=24h"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;When to use:&lt;/strong&gt; after running short-lived containers during testing or development, when stopped containers pile up over time, or to free up space without affecting running containers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Clean Docker Images with docker image prune
&lt;/h2&gt;

&lt;p&gt;Removes unused Docker images. By default, it only removes dangling images — images that are untagged and not referenced by any containers. Syntax: &lt;code&gt;docker image prune [OPTIONS]&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Remove all dangling images:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker image prune
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Remove all unused images (not just dangling ones):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker image prune &lt;span class="nt"&gt;--all&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Remove unused images older than 72 hours:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker image prune &lt;span class="nt"&gt;--all&lt;/span&gt; &lt;span class="nt"&gt;--filter&lt;/span&gt; &lt;span class="s2"&gt;"until=72h"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;When to use:&lt;/strong&gt; after building or pulling many temporary images, when running out of disk space due to image layers, or to clean up old application builds not referenced by containers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Clean Docker Volumes with docker volume prune
&lt;/h2&gt;

&lt;p&gt;Removes volumes that are not referenced by any containers. Active or attached volumes are not affected. Syntax: &lt;code&gt;docker volume prune [OPTIONS]&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Remove all unused volumes interactively:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker volume prune
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Remove all unused volumes without confirmation:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker volume prune &lt;span class="nt"&gt;--force&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;When to use:&lt;/strong&gt; after deleting containers that previously used persistent volumes, when temporary or test volumes accumulate over time, or to recover disk space tied to orphaned data.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Warning:&lt;/strong&gt; Volume data is not recoverable after deletion. Always verify which volumes are in use before pruning.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Clean Docker Networks with docker network prune
&lt;/h2&gt;

&lt;p&gt;Removes Docker networks that are not connected to any running or stopped containers. Syntax: &lt;code&gt;docker network prune [OPTIONS]&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Remove all unused networks interactively:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker network prune
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Remove all unused networks without confirmation:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker network prune &lt;span class="nt"&gt;--force&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;When to use:&lt;/strong&gt; after removing containers created with &lt;code&gt;docker-compose&lt;/code&gt;, when testing multi-container applications, or to clean up orphaned or auto-generated bridge networks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Clean Docker Build Cache with docker builder prune
&lt;/h2&gt;

&lt;p&gt;Removes the build cache created during image builds. By default, it only removes dangling (unused) cache layers. Syntax: &lt;code&gt;docker builder prune [OPTIONS]&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Remove dangling build cache interactively:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker builder prune
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Remove all unused build cache without confirmation:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker builder prune &lt;span class="nt"&gt;--all&lt;/span&gt; &lt;span class="nt"&gt;--force&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;When to use:&lt;/strong&gt; after frequent image builds during development, when low on disk space, or to clean up intermediate cache layers that are no longer referenced.&lt;/p&gt;

&lt;h2&gt;
  
  
  Troubleshooting Docker Prune Issues
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Docker Prune Doesn't Remove Everything
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; Docker only removes unused resources. If a container or volume is still referenced, it won't be pruned.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Stop the container:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker container stop &amp;lt;container_id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Remove the container:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker container &lt;span class="nb"&gt;rm&lt;/span&gt; &amp;lt;container_id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Run prune again:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker system prune
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Cannot Delete Volume Because It's In Use
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; The volume is still attached to a container.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. List all volumes:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker volume &lt;span class="nb"&gt;ls&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Inspect the volume to see where it's used:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker volume inspect &amp;lt;volume_name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Remove the attached container:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker container &lt;span class="nb"&gt;rm&lt;/span&gt; &amp;lt;container_id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Then prune volumes:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker volume prune
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Docker Disk Usage Still High
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; Some resources are still referenced or were not covered by the last prune command.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Check the disk usage summary:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker system &lt;span class="nb"&gt;df&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Run targeted prune commands:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker image prune
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker volume prune
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Run a full cleanup (if safe to do so):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker system prune &lt;span class="nt"&gt;--all&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Schedule &lt;code&gt;docker system df&lt;/code&gt; and a filtered &lt;code&gt;docker system prune --filter "until=24h"&lt;/code&gt; as a recurring job instead of running cleanup manually.&lt;/li&gt;
&lt;li&gt;Standardize on &lt;code&gt;--filter "until=Xh"&lt;/code&gt; across your team's cleanup scripts to avoid accidentally removing resources still in active use.&lt;/li&gt;
&lt;li&gt;Add a &lt;code&gt;docker volume ls&lt;/code&gt; check to your deployment pipeline before pruning volumes, since volume data isn't recoverable.&lt;/li&gt;
&lt;li&gt;Review &lt;code&gt;docker builder prune --all&lt;/code&gt; periodically on CI build hosts where cache layers accumulate quickly.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the full guide with additional tips, visit the original article on &lt;strong&gt;&lt;a href="https://docs.vultr.com/how-to-clean-up-docker-with-prune" rel="noopener noreferrer"&gt;Vultr Docs&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>containers</category>
      <category>devops</category>
      <category>cli</category>
    </item>
    <item>
      <title>Using Volumes in Docker</title>
      <dc:creator>Sanskriti Harmukh</dc:creator>
      <pubDate>Thu, 29 Oct 2026 17:08:50 +0000</pubDate>
      <link>https://dev.to/vultr/using-volumes-in-docker-454o</link>
      <guid>https://dev.to/vultr/using-volumes-in-docker-454o</guid>
      <description>&lt;p&gt;Docker volumes are a persistent storage mechanism that decouples your data from the container lifecycle, letting containers retain data across restarts and removals and allowing multiple containers to share a common data source. Unlike bind mounts, Docker manages volumes internally and stores them under &lt;code&gt;/var/lib/docker/volumes/&lt;/code&gt; on Linux systems. This guide shows how to create and inspect Docker volumes, interact with their contents, use them in Docker Compose workflows, back up and restore volume data, and reference volumes with the &lt;code&gt;VOLUME&lt;/code&gt; instruction in a Dockerfile. By the end, you'll have a container with a named, persistent volume that you can inspect, back up, restore, and manage through both the CLI and Docker Compose.&lt;/p&gt;




&lt;h2&gt;
  
  
  Quick Reference
&lt;/h2&gt;

&lt;p&gt;The following commands demonstrate how to manage persistent data using volumes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker volume create web_content
&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker container run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; web_content:/app/data &lt;span class="nt"&gt;--name&lt;/span&gt; volume_demo httpd
&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker volume &lt;span class="nb"&gt;ls&lt;/span&gt;
&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker volume inspect web_content
&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker volume &lt;span class="nb"&gt;rm &lt;/span&gt;web_content
&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker volume prune
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  When to Use Docker Volumes
&lt;/h2&gt;

&lt;p&gt;Use Docker volumes instead of bind mounts when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You want data to persist across container restarts or removals.&lt;/li&gt;
&lt;li&gt;You need consistent storage behavior across Linux, macOS, and Windows.&lt;/li&gt;
&lt;li&gt;You prefer Docker-managed storage lifecycle and internal volume handling.&lt;/li&gt;
&lt;li&gt;You plan to back up or restore application data regularly.&lt;/li&gt;
&lt;li&gt;You need to share persistent data between multiple containers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Bind mounts are more suitable for development environments where code changes on the host need to reflect immediately in the container. For production environments, Docker volumes are the preferred choice due to their portability, safety, and lifecycle integration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Manually Create and Link Volumes
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Create a Docker volume:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker volume create web_content
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a Docker-managed volume named &lt;code&gt;web_content&lt;/code&gt;. Docker stores it internally and tracks its metadata.&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Run a container and mount the volume:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker container run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; web_content:/usr/local/apache2/htdocs &lt;span class="nt"&gt;--name&lt;/span&gt; apache_with_volume httpd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This launches a container with the &lt;code&gt;httpd&lt;/code&gt; image and mounts the named volume at the web server's root. &lt;code&gt;-d&lt;/code&gt; runs the container in detached mode, &lt;code&gt;-v web_content:/usr/local/apache2/htdocs&lt;/code&gt; mounts the volume to Apache's web root, and &lt;code&gt;--name apache_with_volume&lt;/code&gt; assigns the container a custom name.&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;03d0120e51dd822148d4c4c0464473cdad8a916e22ba5685ec495e47573dc722
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. List all volumes:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker volume &lt;span class="nb"&gt;ls&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DRIVER    VOLUME NAME
local     web_content
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Inspect the volume:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker volume inspect web_content
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This confirms the volume's internal mount path and attributes, useful for debugging and manual access.&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="nl"&gt;"CreatedAt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2025-06-06T17:38:52Z"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="nl"&gt;"Driver"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"local"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="nl"&gt;"Labels"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="nl"&gt;"Mountpoint"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/var/lib/docker/volumes/web_content/_data"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="nl"&gt;"Name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"web_content"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="nl"&gt;"Options"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="nl"&gt;"Scope"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"local"&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. List all containers:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker container &lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CONTAINER ID   IMAGE     COMMAND              CREATED          STATUS          PORTS     NAMES
03d0120e51dd   httpd     "httpd-foreground"   46 seconds ago   Up 45 seconds   80/tcp    apache_with_volume
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6. Check volume usage by container:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker container inspect &lt;span class="nt"&gt;--format&lt;/span&gt;&lt;span class="o"&gt;={{&lt;/span&gt;.Mounts&lt;span class="o"&gt;}}&lt;/span&gt; apache_with_volume
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This shows where the volume is mounted inside the container, validating its usage path.&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="err"&gt;volume&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;web_content&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;/var/lib/docker/volumes/web_content/_data&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;/usr/local/apache&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="err"&gt;/htdocs&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;local&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;z&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;7. Stop the container:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker container stop apache_with_volume
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This halts the container without removing it, preserving the volume and data.&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;8. Remove the container:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker container &lt;span class="nb"&gt;rm &lt;/span&gt;apache_with_volume
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This removes the container while leaving the named volume intact for reuse.&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;9. Remove the volume:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker volume &lt;span class="nb"&gt;rm &lt;/span&gt;web_content
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This permanently removes the volume and its contents.&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Warning:&lt;/strong&gt; Removing a volume deletes all stored data. Ensure backups exist before running this command in production environments.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Use Volumes in Dockerfiles
&lt;/h2&gt;

&lt;p&gt;While Dockerfiles can't create named volumes, they can define mount points expected at runtime using the &lt;code&gt;VOLUME&lt;/code&gt; instruction. Docker automatically creates an anonymous volume for such paths unless you explicitly mount a named one when running the container.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Navigate to the user's home directory and create a &lt;code&gt;docker&lt;/code&gt; directory:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ~
&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;docker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Navigate into the new directory:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;docker/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Create a Dockerfile:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;nano Dockerfile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Add the following content to the Dockerfile:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; httpd&lt;/span&gt;
&lt;span class="k"&gt;VOLUME&lt;/span&gt;&lt;span class="s"&gt; ["/usr/local/apache2/htdocs"]&lt;/span&gt;
&lt;span class="k"&gt;CMD&lt;/span&gt;&lt;span class="s"&gt; ["httpd-foreground"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save and close the file. This Dockerfile builds an Apache-based image that treats &lt;code&gt;/usr/local/apache2/htdocs&lt;/code&gt; as a volume path.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Build the image:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker image build &lt;span class="nt"&gt;-t&lt;/span&gt; apache_with_volume &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This builds the Dockerfile and creates a new image named &lt;code&gt;apache_with_volume&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[+] Building 0.1s (5/5) FINISHED                            docker:default
 =&amp;gt; [internal] load build definition from Dockerfile        0.0s
 =&amp;gt; =&amp;gt; transferring dockerfile: 110B                        0.0s
 =&amp;gt; [internal] load metadata for docker.io/library/httpd    0.0s
 =&amp;gt; =&amp;gt; writing image sha256:c886f948f696b...                0.0s
 =&amp;gt; =&amp;gt; naming to docker.io/library/apache_with_volume       0.0s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6. Run the container:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker container run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;--rm&lt;/span&gt; apache_with_volume
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;-d&lt;/code&gt; runs the container in detached mode, and &lt;code&gt;--rm&lt;/code&gt; automatically removes the container when it exits. Docker automatically creates an anonymous volume and mounts it at &lt;code&gt;/usr/local/apache2/htdocs&lt;/code&gt;, as defined in the Dockerfile.&lt;/p&gt;

&lt;p&gt;To use a named volume instead of an anonymous one, pass the &lt;code&gt;-v&lt;/code&gt; flag explicitly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker container run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;--rm&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; web_content:/usr/local/apache2/htdocs apache_with_volume
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This lets you control the volume lifecycle while still benefiting from Dockerfile-defined mount points.&lt;/p&gt;

&lt;h2&gt;
  
  
  Interact with Docker Volumes
&lt;/h2&gt;

&lt;p&gt;Docker does not let you directly mount volumes on the host system, but you can access and modify volume contents from within a running container.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Start a container with the volume mounted:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker container run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;--name&lt;/span&gt; apache_with_volume &lt;span class="nt"&gt;-v&lt;/span&gt; web_content:/usr/local/apache2/htdocs httpd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;03d0120e51dd8221...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Create an HTML file on your host machine:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;h1&amp;gt;Hello Apache from docker volume&amp;lt;/h1&amp;gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Copy the file into the container:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker &lt;span class="nb"&gt;cp &lt;/span&gt;index.html apache_with_volume:/usr/local/apache2/htdocs/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Successfully copied 2.05kB to apache_with_volume:/usr/local/apache2/htdocs/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. View the file contents inside the container:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker &lt;span class="nb"&gt;exec &lt;/span&gt;apache_with_volume &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="go"&gt;   cat /usr/local/apache2/htdocs/index.html
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Hello Apache from docker volume&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Back up the volume from inside the container:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker &lt;span class="nb"&gt;exec &lt;/span&gt;apache_with_volume &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="go"&gt;   tar czf /usr/local/apache2/htdocs/httpd_backup.tar.gz -C /usr/local/apache2/htdocs .
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a compressed &lt;code&gt;.tar.gz&lt;/code&gt; archive of the volume's contents inside the container.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Copy the backup file from the container to the host:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker &lt;span class="nb"&gt;cp &lt;/span&gt;apache_with_volume:/usr/local/apache2/htdocs/httpd_backup.tar.gz &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Successfully copied 2.05kB to /home/john/docker/.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;7. Restore the volume by copying the archive back and extracting it:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker &lt;span class="nb"&gt;cp &lt;/span&gt;httpd_backup.tar.gz apache_with_volume:/usr/local/apache2/htdocs/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker &lt;span class="nb"&gt;exec &lt;/span&gt;apache_with_volume &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="go"&gt;   tar xzf /usr/local/apache2/htdocs/httpd_backup.tar.gz -C /usr/local/apache2/htdocs
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first command copies the backup archive into the container, and the second extracts its contents into the volume directory.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use Volumes with Docker Compose
&lt;/h2&gt;

&lt;p&gt;Docker Compose supports named volumes natively — they're automatically created and managed alongside the service lifecycle.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Create a &lt;code&gt;docker-compose&lt;/code&gt; directory in your home path:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ~
&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;docker-compose
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Navigate to the new directory:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;docker-compose/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Create a &lt;code&gt;docker-compose.yml&lt;/code&gt; manifest:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;nano docker-compose.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Add the following YAML content to the file:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
   &lt;span class="na"&gt;web&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
       &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;httpd&lt;/span&gt;
       &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
           &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;web_content:/usr/local/apache2/htdocs&lt;/span&gt;

&lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
   &lt;span class="na"&gt;web_content&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This tells Docker Compose to create a volume named &lt;code&gt;web_content&lt;/code&gt; and mount it to the container at &lt;code&gt;/usr/local/apache2/htdocs&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Start the service:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker compose up &lt;span class="nt"&gt;-d&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This builds and runs the container while automatically creating the declared volume and network.&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[+] Running 3/3
✔ Network docker-compose_default       Created                    0.2s 
✔ Volume "docker-compose_web_content"  Created                    0.0s 
✔ Container docker-compose-web-1       Started                    0.6s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6. Inspect the volume created by Docker Compose:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker volume inspect docker-compose_web_content
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;docker-compose_web_content&lt;/code&gt; with the name of your Docker Compose volume. This confirms that the named volume declared in the Compose file was created and is mounted as expected.&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"Name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"docker-compose_web_content"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"Mountpoint"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/var/lib/docker/volumes/docker-compose_web_content/_data"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;7. Shut down the service and remove the volume:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker compose down &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;down&lt;/code&gt; stops and removes containers, networks, and volumes, and &lt;code&gt;-v&lt;/code&gt; ensures that named volumes declared in the Compose file are also deleted.&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[+] Running 3/3
✔ Container docker-compose-web-1     Removed                      1.3s 
✔ Network docker-compose_default     Removed                      0.2s 
✔ Volume docker-compose_web_content  Removed                      0.0s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Move your own stateful services (databases, CMS uploads, app data) from bind mounts to named volumes for safer, more portable persistence.&lt;/li&gt;
&lt;li&gt;Script the backup/restore workflow (&lt;code&gt;tar&lt;/code&gt; inside the container + &lt;code&gt;docker cp&lt;/code&gt;) into a reusable shell script you can run on a schedule.&lt;/li&gt;
&lt;li&gt;Add volume definitions to an existing Docker Compose project instead of managing volumes manually with the CLI.&lt;/li&gt;
&lt;li&gt;Review &lt;code&gt;docker volume prune&lt;/code&gt; to clean up unused volumes once you're comfortable with which ones are safe to remove.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the full guide with additional tips, visit the original article on &lt;strong&gt;&lt;a href="https://docs.vultr.com/how-to-use-volumes-in-docker" rel="noopener noreferrer"&gt;Vultr Docs&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>containers</category>
      <category>devops</category>
      <category>linux</category>
    </item>
  </channel>
</rss>
