<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ virtualization - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ virtualization - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Fri, 19 Jun 2026 06:37:10 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/virtualization/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to Activate Your Django Virtual Environment ]]>
                </title>
                <description>
                    <![CDATA[ If you’re starting with Django, one of the first steps you’ll hear about is activating a virtual environment. And if that sounds a little technical, don’t worry – I’m going to walk you through exactly what that means, why it matters, and how to do it... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-activate-your-django-virtual-environment/</link>
                <guid isPermaLink="false">6877da442945848c5461548c</guid>
                
                    <category>
                        <![CDATA[ Python ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Django ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtualization ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Udemezue John ]]>
                </dc:creator>
                <pubDate>Wed, 16 Jul 2025 16:58:44 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1746123776834/337004ca-692e-4df9-89db-81e78a16c7fe.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>If you’re starting with Django, one of the first steps you’ll hear about is <em>activating a virtual environment</em>. And if that sounds a little technical, don’t worry – I’m going to walk you through exactly what that means, why it matters, and how to do it step-by-step, without any confusing terms.</p>
<p>I’ve helped a lot of people get started with Python and Django, and trust me: understanding virtual environments early on can save you tons of headaches later.</p>
<p>A virtual environment can help you keep your Django projects organized. It also avoids conflicts between different versions of packages, and gives you a cleaner way to manage your development tools.</p>
<p>By the end of this guide, you’ll not only know how to activate your virtual environment, but also why you should.</p>
<p>Let's get into it.</p>
<h3 id="heading-heres-what-well-cover">Here’s what we’ll cover:</h3>
<ol>
<li><p><a class="post-section-overview" href="#heading-what-is-a-virtual-environment-in-python">What Is a Virtual Environment in Python?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-why-use-a-virtual-environment">Why Use a Virtual Environment?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-set-up-and-activate-a-django-virtual-environment">How to Set Up and Activate a Django Virtual Environment</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-1-install-python-if-you-havent-yet">1. Install Python (If You Haven’t Yet)</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-2-install-virtualenv-optional-but-useful">2. Install virtualenv (Optional but Useful)</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-3-create-a-virtual-environment">3. Create a Virtual Environment</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-4-activate-the-virtual-environment">4. Activate the Virtual Environment</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-what-can-you-do-after-activating-it">What Can You Do After Activating It?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-deactivate-the-virtual-environment">How to Deactivate the Virtual Environment</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-faqs">FAQs</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-do-i-need-to-activate-the-environment-every-time">Do I need to activate the environment every time?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-what-if-activate-doesnt-work">What if activate Doesn’t work?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-can-i-use-vs-code-or-another-editor-with-this">Can I use VS Code or another editor with this?</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-bonus-tips">Bonus Tips</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-add-a-gitignore-file">Add a .gitignore File</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-use-requirementstxt">Use requirements.txt</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-helpful-resources">Helpful Resources</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-further-learning">Further Learning</a></p>
</li>
</ol>
<h2 id="heading-what-is-a-virtual-environment-in-python">What Is a Virtual Environment in Python?</h2>
<p>A virtual environment is like a private workspace just for your project. Instead of installing packages (like Django) globally for your whole computer, you install them inside this little bubble. That way, different projects don’t mess with each other.</p>
<p>Imagine you’re working on two Django projects: one needs Django 3.2 and the other needs Django 4.1. Without a virtual environment, you'd run into version conflicts. But with virtual environments, each project stays separate and clean.</p>
<h2 id="heading-why-use-a-virtual-environment">Why Use a Virtual Environment?</h2>
<p>Here’s why I <em>always</em> use one when working with Django:</p>
<ul>
<li><p>Keeps your project dependencies isolated.</p>
</li>
<li><p>Prevents version conflicts between different projects.</p>
</li>
<li><p>Makes it easy to manage and uninstall packages.</p>
</li>
<li><p>Most importantly, <strong>Django expects it</strong>, especially if you want to follow best practices.</p>
</li>
</ul>
<h2 id="heading-how-to-set-up-and-activate-a-django-virtual-environment">How to Set Up and Activate a Django Virtual Environment</h2>
<p>Let’s walk through the process from start to finish.</p>
<h3 id="heading-1-install-python-if-you-havent-yet">1. <strong>Install Python (If You Haven’t Yet)</strong></h3>
<p>You need Python 3.8 or later. You can check what version you have by opening your terminal and typing:</p>
<pre><code class="lang-bash">python --version
</code></pre>
<p>If you see something like <code>Python 3.11.7</code>You’re good.</p>
<p>If you don’t have Python, download it here:</p>
<p>👉 <a target="_blank" href="https://www.python.org/downloads/">https://www.python.org/downloads/</a></p>
<p>Make sure to check the box <strong>“Add Python to PATH”</strong> during installation if you're on Windows.</p>
<h3 id="heading-2-install-virtualenv-optional-but-worth-knowing">2. Install <code>virtualenv</code> (Optional but Worth Knowing)</h3>
<p>Python includes a built-in tool called <code>venv</code>, and that’s what we’ll use in this tutorial.</p>
<p>However, some developers prefer <code>virtualenv</code> because:</p>
<ul>
<li><p>It works with older Python versions</p>
</li>
<li><p>It can be slightly faster in larger environments</p>
</li>
<li><p>It offers some additional flexibility</p>
</li>
</ul>
<p>To install <code>virtualenv</code> just run:</p>
<pre><code class="lang-bash">pip install virtualenv
</code></pre>
<p><strong>Note:</strong> You don’t need <code>virtualenv</code> for this tutorial, but it’s good to know about. We'll be using Python’s built-in <code>venv</code> going forward.</p>
<h3 id="heading-3-create-a-virtual-environment">3. <strong>Create a Virtual Environment</strong></h3>
<p>Now go to your Django project folder (or make one):</p>
<pre><code class="lang-bash">mkdir my_django_project
<span class="hljs-built_in">cd</span> my_django_project
</code></pre>
<p>Then run:</p>
<pre><code class="lang-bash">python -m venv venv
</code></pre>
<ul>
<li><p><code>python -m venv</code> uses Python’s built-in virtual environment module</p>
</li>
<li><p><code>venv</code> is the name of the folder that will store your environment (you can call it anything)</p>
</li>
</ul>
<p>This creates a folder called <code>venv/</code> in your project directory. That folder contains everything your virtual environment needs.</p>
<h3 id="heading-4-activate-the-virtual-environment">4. <strong>Activate the Virtual Environment</strong></h3>
<p>Here’s the part everyone asks about.</p>
<p>Activation depends on your operating system.</p>
<h4 id="heading-on-windows-cmd">On <strong>Windows (CMD)</strong>:</h4>
<pre><code class="lang-bash">venv\Scripts\activate
</code></pre>
<h4 id="heading-on-windows-powershell">On <strong>Windows (PowerShell)</strong>:</h4>
<pre><code class="lang-bash">.\venv\Scripts\Activate.ps1
</code></pre>
<h4 id="heading-on-mac-or-linux">On <strong>Mac or Linux</strong>:</h4>
<pre><code class="lang-bash"><span class="hljs-built_in">source</span> venv/bin/activate
</code></pre>
<p>After you activate it, your terminal prompt will change. It’ll look something like this:</p>
<pre><code class="lang-bash">(venv) your-computer-name:my_django_project username$
</code></pre>
<p>That <code>(venv)</code> at the beginning means the virtual environment is active.</p>
<h2 id="heading-what-can-you-do-after-activating-it">What Can You Do After Activating It?</h2>
<p>Now that it’s active, you can install Django (or anything else) just for this project:</p>
<pre><code class="lang-bash">pip install django
</code></pre>
<p>This installs Django inside the virtual environment, not globally.</p>
<p>To double-check:</p>
<pre><code class="lang-bash">pip list
</code></pre>
<p>You’ll see Django and any other installed packages listed there.</p>
<h2 id="heading-how-to-deactivate-the-virtual-environment">How to Deactivate the Virtual Environment</h2>
<p>When you’re done working, just type:</p>
<pre><code class="lang-bash">deactivate
</code></pre>
<p>That’s it. Your terminal goes back to normal, and your system’s Python is no longer linked to the project.</p>
<h2 id="heading-faqs">FAQs</h2>
<h3 id="heading-do-i-need-to-activate-the-environment-every-time"><strong>Do I need to activate the environment every time?</strong></h3>
<p>Yes, every time you open a new terminal session and want to work on your Django project, activate it again using the command for your OS.</p>
<h3 id="heading-what-if-activate-doesnt-work"><strong>What if</strong> <code>activate</code> <strong>Doesn’t work?</strong></h3>
<p>If you’re on Windows, PowerShell might block the script. Run this:</p>
<pre><code class="lang-powershell"><span class="hljs-built_in">Set-ExecutionPolicy</span> <span class="hljs-literal">-ExecutionPolicy</span> RemoteSigned <span class="hljs-literal">-Scope</span> CurrentUser
</code></pre>
<p>Then try activating again.</p>
<h3 id="heading-can-i-use-vs-code-or-another-editor-with-this"><strong>Can I use VS Code or another editor with this?</strong></h3>
<p>Absolutely. VS Code even detects your virtual environment automatically. You can select the interpreter from the bottom-left or by pressing <code>Ctrl+Shift+P</code> → “Python: Select Interpreter.”</p>
<h2 id="heading-bonus-tips">Bonus Tips</h2>
<h3 id="heading-add-a-gitignore-file">Add a <code>.gitignore</code> File</h3>
<p>If you're using Git, you don’t want to upload the <code>venv</code> folder to GitHub. Add this line to your <code>.gitignore</code> file:</p>
<pre><code class="lang-python">venv/
</code></pre>
<h3 id="heading-use-requirementstxt">Use <code>requirements.txt</code></h3>
<p>Once you’ve installed your project’s packages, freeze them like this:</p>
<pre><code class="lang-bash">pip freeze &gt; requirements.txt
</code></pre>
<p>Then later, you (or someone else) can install them with:</p>
<pre><code class="lang-bash">pip install -r requirements.txt
</code></pre>
<p>This is useful for team projects or for moving your app to a server.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Activating your Django virtual environment might seem like a small thing, but it’s a big step toward becoming a confident and organized developer.</p>
<p>Once you get the hang of it, it becomes second nature – and your future self will thank you for learning it the right way from the start.</p>
<p>Would you love to connect with me? You can do so on <a target="_blank" href="https://X.com/_udemezue">X.com/_udemezue</a></p>
<h3 id="heading-helpful-resources">Helpful Resources</h3>
<ul>
<li><p><a target="_blank" href="https://docs.python.org/3/library/venv.html">Official Python Docs on <code>venv</code></a></p>
</li>
<li><p><a target="_blank" href="https://www.djangoproject.com/">Django Official Website</a></p>
</li>
<li><p><a target="_blank" href="https://realpython.com/python-virtual-environments-a-primer/">Python Virtual Environments Tutorial (Real Python)</a></p>
</li>
<li><p><a target="_blank" href="https://stackoverflow.com/questions/63443862/activate-ps1-cannot-be-loaded-because-running-scripts-is-disabled">How to Fix “activate.ps1 cannot be loaded” in PowerShell</a></p>
</li>
</ul>
<h3 id="heading-further-learning">Further Learning</h3>
<p>If you're serious about Django, here are some free and paid resources I recommend:</p>
<ul>
<li><p><a target="_blank" href="https://djangoforbeginners.com/">Django for Beginners by William S. Vincent</a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=F5mRW0jo-U4">FreeCodeCamp’s Django Crash Course on YouTube</a></p>
</li>
<li><p><a target="_blank" href="https://cs50.harvard.edu/web/2020/">CS50 Web Programming with Python and JavaScript</a></p>
</li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Turn Ubuntu 24.04 into a KVM Hypervisor – Quick Setup with Web Management ]]>
                </title>
                <description>
                    <![CDATA[ Virtualization lets you run multiple operating systems on one machine. It’s perfect for testing apps, hosting servers, or learning DevOps. A hypervisor is the software that lets you run multiple virtual machines on a single physical machine, and the ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/turn-ubuntu-2404-into-a-kvm-hypervisor/</link>
                <guid isPermaLink="false">680fa285102a9fb019d4fa34</guid>
                
                    <category>
                        <![CDATA[ KVM ]]>
                    </category>
                
                    <category>
                        <![CDATA[ hypervisor ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtualization ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtual machine ]]>
                    </category>
                
                    <category>
                        <![CDATA[ vm ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Shamsuddoha Ranju ]]>
                </dc:creator>
                <pubDate>Mon, 28 Apr 2025 15:45:09 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1745591647377/613d9a44-cc2b-45b7-b1d1-5fc3154b9623.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Virtualization lets you run multiple operating systems on one machine. It’s perfect for testing apps, hosting servers, or learning DevOps.</p>
<p>A hypervisor is the software that lets you run multiple virtual machines on a single physical machine, and the Kernel-based Virtual Machine (KVM) is one of the best. Built into Linux, KVM is fast (near-native performance), open-source (free!), and flexible (supports Windows, Linux, and more). It’s trusted by both cloud providers and homelabbers for its stability and low overhead.</p>
<p>If you want to turn your Ubuntu 24.04 or Kubuntu 24.04 (Kubuntu is a Ubuntu variant with KDE Plasma desktop) system into a powerful hypervisor without <strong>Proxmox</strong>’s complexity, this guide is for you. With KVM, you’ll spin up virtual machines (VMs) in minutes, and with Cockpit’s web-based manager, you’ll control them from your browser.</p>
<p>In this tutorial, you’ll transform an Ubuntu 24.04 or Kubuntu 24.04 Desktop or Server – fresh or existing – into a KVM hypervisor. You’ll set up the backend (KVM, QEMU, libvirt), add Cockpit for web-based VM management, and create a guest VM to test it all. Whether you’re a coder, homelabber, or IT enthusiast, this guide is beginner-friendly.</p>
<h2 id="heading-table-of-contents">Table of Contents</h2>
<ul>
<li><p><a class="post-section-overview" href="#heading-before-you-start-what-you-should-know">Before You Start: What You Should Know</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-what-youll-need">What You’ll Need</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-why-kvm-on-ubuntukubuntu-2404">Why KVM on Ubuntu/Kubuntu 24.04?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-1-check-virtualization-support">Step 1: Check Virtualization Support</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-2-install-kvm-and-backend-tools">Step 2: Install KVM and Backend Tools</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-3-set-up-a-network-bridge">Step 3: Set Up a Network Bridge</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-4-install-cockpit-for-web-management">Step 4: Install Cockpit for Web Management</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-5-create-a-guest-vm">Step 5: Create a Guest VM</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-6-run-and-test-your-guest-vm">Step 6: Run and Test Your Guest VM</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-keep-exploring-your-hypervisor">Keep Exploring Your Hypervisor</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-wrapping-up">Wrapping Up</a></p>
</li>
</ul>
<h2 id="heading-before-you-start-what-you-should-know">Before You Start: What You Should Know</h2>
<p>This guide is designed for virtualization newcomers, but you’ll need a few basic skills:</p>
<ul>
<li><p>Running terminal commands like <code>sudo apt install</code> or <code>nano</code> and so on.</p>
</li>
<li><p>Basic Linux navigation (for example, editing files in <code>/etc</code>).</p>
</li>
<li><p>Basic networking knowledge, such as understanding network interfaces (for example, <code>enp4s0</code> or <code>wlp3s0</code>), IP addresses, and concepts like bridging or NAT. You’ll use tools like <code>ip link</code> or <code>nmcli</code> to set up a network bridge in Step 3.</p>
</li>
<li><p>Optional: Experience with VMs helps but isn’t required – I’ll explain everything.</p>
</li>
</ul>
<p>No worries if terms like “libvirt” sound new. I’ll break them down as we go.</p>
<h2 id="heading-what-youll-need">What You’ll Need</h2>
<ul>
<li><p><strong>A computer</strong>: Running Ubuntu 24.04 or Kubuntu 24.04 Desktop or Server (fresh or existing). Minimum: 4GB RAM, 20GB storage, CPU with virtualization support (Intel VT-x or AMD-V). More RAM/storage for multiple VMs.</p>
</li>
<li><p><strong>Internet access</strong>: To download packages and VM ISOs.</p>
</li>
<li><p><strong>A web browser</strong>: Firefox (default on Ubuntu) or Chrome to access Cockpit.</p>
</li>
<li><p><strong>An ISO image</strong>: An ISO image for your guest VM (for example, Ubuntu 24.04 Desktop ISO from ubuntu.com or Windows ISO if you have it already).</p>
</li>
<li><p><strong>30–45 minutes</strong>: Depending on your setup speed.</p>
</li>
</ul>
<h2 id="heading-why-kvm-on-ubuntukubuntu-2404">Why KVM on Ubuntu/Kubuntu 24.04?</h2>
<p>KVM turns your Linux kernel into a hypervisor, letting you run VMs with near-native speed. Paired with QEMU (for hardware emulation) and libvirt (for management), it’s a lightweight alternative to <strong>Proxmox</strong> or <strong>VMware</strong>. Its strengths include:</p>
<ul>
<li><p><strong>Performance</strong>: Runs VMs efficiently, ideal for homelabs or dev environments.</p>
</li>
<li><p><strong>Free and Open-Source</strong>: No licenses, just like Ubuntu/Kubuntu, and so on.</p>
</li>
<li><p><strong>Flexibility</strong>: Supports diverse guest OSs (Linux, Windows, BSD).</p>
</li>
<li><p><strong>Integration</strong>: Cockpit’s web UI makes VM management a breeze, no CLI required.</p>
</li>
</ul>
<p>Here’s what each tool does:</p>
<ul>
<li><p><strong>KVM</strong>: A Linux kernel module that turns your system into a hypervisor, enabling VMs to run with near-native performance by leveraging CPU virtualization features (for example, Intel VT-x).</p>
</li>
<li><p><strong>QEMU</strong>: A powerful emulator that provides the virtual hardware (for example, CPU, disk, network) for your VMs, working with KVM for fast execution.</p>
</li>
<li><p><strong>libvirt</strong>: A management layer that simplifies VM creation, networking, and storage, offering tools like <code>virsh</code> and APIs for automation.</p>
</li>
<li><p><strong>Cockpit</strong>: A web-based interface for managing VMs, system resources, and networks, perfect for beginners who want a visual dashboard.</p>
</li>
</ul>
<p>Ubuntu 24.04 (“Noble Numbat”) brings the latest kernel and tools, ensuring top-notch KVM compatibility. Let’s build your hypervisor!</p>
<h2 id="heading-step-1-check-virtualization-support">Step 1: Check Virtualization Support</h2>
<p>First, you’ll want to confirm that your CPU supports virtualization (most modern ones do). To do that, open a terminal (like Konsole on Kubuntu) and run:</p>
<pre><code class="lang-bash">lscpu | grep Virtualization
</code></pre>
<p>Look for "VT-x" (Intel) or "AMD-V" (AMD). If present, you’re good!</p>
<p>If nothing shows, check your BIOS/UEFI:</p>
<ul>
<li><p>Reboot, enter BIOS (usually <code>F2</code>, <code>Del</code>, or <code>Esc</code>).</p>
</li>
<li><p>Enable "Intel VT-x" or "AMD-V" under CPU settings.</p>
</li>
<li><p>Save and reboot.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745226012162/337e2324-50b3-4bd9-b040-01c2ac919e7c.png" alt="Konsole terminal on Kubuntu displaying ‘lscpu | grep Virtualization’ output confirming VT-x support for KVM." class="image--center mx-auto" width="911" height="508" loading="lazy"></p>
<h2 id="heading-step-2-install-kvm-and-backend-tools">Step 2: Install KVM and Backend Tools</h2>
<p>Let’s install KVM, QEMU, and libvirt. These will form the backbone of your hypervisor:</p>
<p>Start by updating your system (you may need to restart your computer after the update):</p>
<pre><code class="lang-bash">sudo apt update &amp;&amp; sudo apt upgrade -y
</code></pre>
<p>Then install the virtualization packages:</p>
<pre><code class="lang-bash">sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils -y
</code></pre>
<ul>
<li><p><code>qemu-kvm</code>: Emulates hardware for VMs.</p>
</li>
<li><p><code>libvirt-daemon-system</code>: Manages VMs.</p>
</li>
<li><p><code>libvirt-clients</code>: CLI tools like <code>virsh</code> for hypervisor management.</p>
</li>
<li><p><code>bridge-utils</code>: For network bridging.</p>
</li>
</ul>
<p>Next, verify that KVM is loaded:</p>
<pre><code class="lang-bash">lsmod | grep kvm
</code></pre>
<p>You’ll see “kvm_intel” or “kvm_amd” if successful.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745226199517/a146d89d-2894-4bbc-b241-11a8ed385758.png" alt="Konsole terminal on Kubuntu displaying ‘lsmod | grep kvm’ output showing kvm_intel module loaded for KVM." class="image--center mx-auto" width="911" height="508" loading="lazy"></p>
<p>Finally, add your (current) user to the <code>libvirt</code> group for permission:</p>
<pre><code class="lang-bash">sudo usermod -aG libvirt <span class="hljs-variable">$USER</span>
</code></pre>
<p>Log out and back in to apply these changes.</p>
<h2 id="heading-step-3-set-up-a-network-bridge">Step 3: Set Up a Network Bridge</h2>
<p>VMs need network access, so you’ll create a bridge (<code>br0</code>) to connect them to your physical network. This allows VMs to act like devices on your network (bridged networking).</p>
<p>Ubuntu 24.04 and Kubuntu 24.04 Desktop typically use NetworkManager, while Ubuntu Server may use Netplan. We’ll prioritize the NetworkManager approach, with Netplan as an alternative.</p>
<p><strong>Note</strong>: Installing libvirt (Step 2) creates a default bridge called <code>virbr0</code> for NAT-based networking, which isolates VMs from the physical network (IPs like <code>192.168.122.x</code>). For direct network access (IPs like <code>192.168.0.x</code>), use <code>br0</code> as described below, and select it in Step 5’s VM setup.</p>
<p>You can verify whether your system is using NetworkManager or Netplan. Open a console and run <code>systemctl status NetworkManager</code>. If you see the status active and running, go with NetworkManager.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745305149513/0926f09c-1748-484f-af4c-37dcb82d06a5.png" alt="Konsole terminal on Kubuntu displaying ‘systemctl status NetworkManager’ output confirming NetworkManager status." class="image--center mx-auto" width="911" height="508" loading="lazy"></p>
<h3 id="heading-option-1-networkmanager-recommended-for-kubuntuubuntu-desktop">Option 1: NetworkManager (Recommended for Kubuntu/Ubuntu desktop)</h3>
<p>Check your network interface:</p>
<pre><code class="lang-bash">ip link
</code></pre>
<p>Example: <code>enp4s0</code>. Replace <code>enp4s0</code> below if yours differs.</p>
<p>First, find your Ethernet connection name:</p>
<pre><code class="lang-bash">nmcli connection show
</code></pre>
<p>Look for the <strong>NAME</strong> column where <strong>DEVICE</strong> is <code>enp4s0</code> (for example, “Wired connection 1” or “Ethernet connection”). Note this name. Ignore <code>virbr0</code>, which is libvirt’s default NAT bridge.</p>
<p>Then create a bridge named <code>br0</code>:</p>
<pre><code class="lang-bash">sudo nmcli connection add <span class="hljs-built_in">type</span> bridge ifname br0 con-name bridge-br0
</code></pre>
<p>Enslave your interface to the bridge:</p>
<pre><code class="lang-bash">sudo nmcli connection add <span class="hljs-built_in">type</span> ethernet ifname enp4s0 master br0 con-name bridge-slave-enp4s0
</code></pre>
<p>Disable the old connection (replace with your connection name identified earlier):</p>
<pre><code class="lang-bash">sudo nmcli connection down <span class="hljs-string">"Wired connection 1"</span>
sudo nmcli connection delete <span class="hljs-string">"Wired connection 1"</span>
</code></pre>
<p>Enable DHCP on the bridge:</p>
<pre><code class="lang-bash">sudo nmcli connection modify bridge-br0 ipv4.method auto
</code></pre>
<p>Activate the bridge:</p>
<pre><code class="lang-bash">sudo nmcli connection up bridge-br0
</code></pre>
<p>Verify:</p>
<pre><code class="lang-bash">ip addr show br0
nmcli connection show
</code></pre>
<p>Now you’ll want to ensure <code>br0</code> is active, <code>enp4s0</code> is enslaved, and <code>virbr0</code> is separate. First, test the internet with <code>ping 8.8.8.8</code>.</p>
<p>Then you need to define <code>br0</code> in libvirt (to appear in Cockpit’s VM network dropdown). To do this, create <code>br0.xml</code> in your home directory:</p>
<pre><code class="lang-bash">nano ~/br0.xml
</code></pre>
<p>Then add the following:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">network</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">name</span>&gt;</span>br0<span class="hljs-tag">&lt;/<span class="hljs-name">name</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">forward</span> <span class="hljs-attr">mode</span>=<span class="hljs-string">'bridge'</span>/&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">bridge</span> <span class="hljs-attr">name</span>=<span class="hljs-string">'br0'</span>/&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">network</span>&gt;</span>
</code></pre>
<p>Save and exit (<code>Ctrl+O</code>, <code>Enter</code>, <code>Ctrl+X</code>).</p>
<p>Now define and start the following:</p>
<pre><code class="lang-bash">sudo virsh net-define ~/br0.xml
sudo virsh net-start br0
sudo virsh net-autostart br0
</code></pre>
<p>Verify like this:</p>
<pre><code class="lang-bash">virsh net-list --all
</code></pre>
<p>You can now delete <code>~/br0.xml</code> after defining, as libvirt stores it in <code>/etc/libvirt/qemu/networks/</code>.</p>
<pre><code class="lang-bash">rm ~/br0.xml
</code></pre>
<h3 id="heading-option-2-netplan-for-ubuntu-server-or-if-preferred">Option 2: Netplan (For Ubuntu Server or If Preferred)</h3>
<p>If you see <code>renderer: networkd</code> in <code>/etc/netplan/???.yaml</code> or prefer Netplan, follow these steps.</p>
<p>First, check your interface:</p>
<pre><code class="lang-bash">ip link
</code></pre>
<p>Example: <code>enp4s0</code>.</p>
<p>Next, edit the Netplan config like so:</p>
<pre><code class="lang-bash">sudo nano /etc/netplan/01-netcfg.yaml
</code></pre>
<p>Use the following:</p>
<pre><code class="lang-yaml"><span class="hljs-attr">network:</span>
  <span class="hljs-attr">version:</span> <span class="hljs-number">2</span>
  <span class="hljs-attr">renderer:</span> <span class="hljs-string">networkd</span>
  <span class="hljs-attr">ethernets:</span>
    <span class="hljs-attr">enp4s0:</span>
      <span class="hljs-attr">dhcp4:</span> <span class="hljs-literal">no</span>
  <span class="hljs-attr">bridges:</span>
    <span class="hljs-attr">br0:</span>
      <span class="hljs-attr">interfaces:</span> [<span class="hljs-string">enp4s0</span>]
      <span class="hljs-attr">dhcp4:</span> <span class="hljs-literal">yes</span>
</code></pre>
<p>Save and exit (<code>Ctrl+O</code>, <code>Enter</code>, <code>Ctrl+X</code>).</p>
<p>Now, set strict permissions to avoid errors:</p>
<pre><code class="lang-bash">sudo chmod 600 /etc/netplan/01-netcfg.yaml
</code></pre>
<p>And apply:</p>
<pre><code class="lang-bash">sudo netplan apply
</code></pre>
<p>Now verify:</p>
<pre><code class="lang-bash">ip addr show br0
</code></pre>
<p>Test the internet with <code>ping 8.8.8.8</code> (from console).</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745227201229/35988335-5ff1-49bc-9809-e9c08d6798c4.png" alt="Konsole terminal on Kubuntu displaying ‘nmcli connection show’ output with bridge-br0 active, enp4s0 enslaved, and virbr0 present for KVM networking." class="image--center mx-auto" width="911" height="508" loading="lazy"></p>
<p><strong>Troubleshooting</strong>:</p>
<ul>
<li><p><strong>Permissions error</strong>: If Netplan complains about “too open” permissions, recheck <code>sudo chmod 600 /etc/netplan/01-netcfg.yaml</code>.</p>
</li>
<li><p><strong>NetworkManager conflict</strong>: If using Netplan, ensure <code>/etc/netplan/01-network-manager-all.yaml</code> is backed up or deleted (<code>sudo mv /etc/netplan/01-network-manager-all.yaml /etc/netplan/01-network-manager-all.yaml.bak</code>).</p>
</li>
<li><p><strong>No onternet</strong>: Restart NetworkManager (<code>sudo systemctl restart NetworkManager</code>) or reboot.</p>
</li>
<li><p><strong>Wrong bridge</strong>: If a VM uses <code>virbr0</code> (NAT, <code>192.168.122.x</code>), recheck Step 5’s network setting and select <code>br0</code>.</p>
</li>
<li><p><strong>br0 missing in Cockpit</strong>: Define <code>br0</code> in libvirt (step 9 above) or ensure <code>br0</code> is active (<code>ip addr show br0</code>).</p>
</li>
</ul>
<h2 id="heading-step-4-install-cockpit-for-web-management">Step 4: Install Cockpit for Web Management</h2>
<p>Cockpit provides a slick web UI to manage VMs. Let’s go ahead and set it up.</p>
<p>First, you’ll need to install Cockpit and its VM plugin:</p>
<pre><code class="lang-bash">sudo apt install cockpit cockpit-machines -y
</code></pre>
<p>Then you can start and enable Cockpit:</p>
<pre><code class="lang-bash">sudo systemctl <span class="hljs-built_in">enable</span> --now cockpit.socket
systemctl status cockpit.socket
</code></pre>
<p>Now open your browser (for example, Firefox on Ubuntu) and visit:</p>
<pre><code class="lang-plaintext">https://localhost:9090
</code></pre>
<p>Or use your KVM server’s IP (for example, <code>https://192.168.0.100:9090</code>) if remote. Log in with your username and password. Ignore the self-signed certificate warning.</p>
<p>Allow Cockpit’s port if you’re using a firewall:</p>
<pre><code class="lang-bash">sudo ufw allow 9090
</code></pre>
<p>You’ll see Cockpit’s dashboard. Turn on administrative access by clicking on “<strong>Turn on administrative access</strong>”. Then, click “<strong>Virtual Machines</strong>” to manage VMs.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745227293385/96291774-d4cf-4de2-9392-3947ade4bb8b.png" alt="Firefox on Kubuntu displaying Cockpit login page at https://localhost:9090 for web-based VM management." class="image--center mx-auto" width="1920" height="1036" loading="lazy"></p>
<h2 id="heading-step-5-create-a-guest-vm">Step 5: Create a Guest VM</h2>
<p>Let’s create a guest VM using Cockpit. We’ll use an Ubuntu 24.04 Desktop ISO as an example:</p>
<p>To start, download the Ubuntu 24.04 Desktop ISO from ubuntu.com and save it (for example, <code>/home/ranju/Downloads/ubuntu-24.04.1-desktop-amd64.iso</code>).</p>
<p>In Cockpit, go to “Virtual Machines” and click “Create VM”. Here are the specs:</p>
<ul>
<li><p><strong>Name</strong>: TestVM</p>
</li>
<li><p><strong>Installation Type</strong>: Local install media (or your desired installation type)</p>
</li>
<li><p><strong>Installation Source</strong>: Browse to your ISO (for example, <code>/home/ranju/Downloads/ubuntu-24.04.1-desktop-amd64.iso</code>).</p>
</li>
<li><p><strong>OS</strong>: Select “Ubuntu 24.04” (usually Cockpit auto-detects).</p>
</li>
<li><p><strong>Storage</strong>: Create new qcow2 volume (preferred). <em>Note: disk is created in</em> <code>/var/lib/libvirt/images/</code><em>.</em></p>
</li>
<li><p><strong>Storage limit</strong>: 20GB (adjust as needed).</p>
</li>
<li><p><strong>Memory</strong>: 4GB (adjust as needed).</p>
</li>
</ul>
<p>Click “Create and Edit”. Cockpit opens an advanced dialog where there are options for customization (for example, CPU, Network Interfaces and Boot order, and so on). Make sure that <code>br0</code> has been selected as interface source. Finally, click “<strong>Install</strong>”.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745228999671/4d80faf7-d8f8-4395-985e-298b4add426c.png" alt="Cockpit web interface in Firefox on Kubuntu showing the Create VM dialog with TestVM settings." class="image--center mx-auto" width="1920" height="1036" loading="lazy"></p>
<p>In Cockpit’s VM console, follow the installer to set up the guest OS (username, password, and so on).</p>
<p><strong>Troubleshooting</strong>:</p>
<ul>
<li><p><strong>Permissions error</strong>: If you have permission error for the ISO, then copy the ISO to the default temp folder (<code>/tmp/</code>) and locate the ISO from there.</p>
<pre><code class="lang-bash">  cp /home/ranju/Downloads/ubuntu-24.04.1.iso /tmp/
</code></pre>
</li>
</ul>
<h2 id="heading-step-6-run-and-test-your-guest-vm">Step 6: Run and Test Your Guest VM</h2>
<p>Your VM is running! Let’s test it:</p>
<ol>
<li><p>In Cockpit, under “Virtual Machines,” click TestVM. You’ll see its console (a live view of the VM’s screen).</p>
</li>
<li><p>Log into the guest Ubuntu using the credentials you set.</p>
</li>
<li><p>Test networking:</p>
<ul>
<li><p>Open a terminal in the VM (via Cockpit’s console).</p>
</li>
<li><p>Run <code>ip addr</code> in the console to confirm a physical network IP (for example, <code>192.168.0.x</code> with <code>br0</code>, not <code>192.168.122.x</code> with <code>virbr0</code>).</p>
</li>
<li><p>Run <code>ping 8.8.8.8</code> to confirm internet access.</p>
</li>
</ul>
</li>
<li><p>Experiment: Open a browser in the VM, visit a website, or install apps to simulate real use.</p>
</li>
</ol>
<p>If the VM boots and connects to your network, your KVM hypervisor is rocking! You can stop, restart, or delete it from Cockpit.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745307664700/ed54d452-4979-4468-a7fe-1dd538844e25.png" alt="Cockpit web interface in Firefox on Kubuntu displaying the TestVM console with Ubuntu 24.04 desktop." class="image--center mx-auto" width="1920" height="1036" loading="lazy"></p>
<h2 id="heading-keep-exploring-your-hypervisor">Keep Exploring Your Hypervisor</h2>
<p>You’ve turned your Ubuntu 24.04 into a KVM hypervisor – congrats! Try these next steps:</p>
<ul>
<li><p><strong>Add more VMs</strong>: Create Windows or other Linux VMs using different ISOs.</p>
</li>
<li><p><strong>Use virt-manager</strong>: Install virt-manager for a desktop-based alternative to Cockpit (<code>sudo apt install virt-manager</code>).</p>
</li>
<li><p><strong>Back up VMs</strong>: Export VM disks with <code>virsh</code> for safety.</p>
</li>
<li><p><strong>Scale up</strong>: Add storage or RAM for heavier workloads, like my Proxmox cluster guide.</p>
</li>
</ul>
<p>Check your VMs anytime via CLI:</p>
<pre><code class="lang-bash">virsh list --all
</code></pre>
<h2 id="heading-wrapping-up">Wrapping Up</h2>
<p>You’ve built a fast, free KVM hypervisor on Ubuntu 24.04, complete with Cockpit’s web UI and a running guest VM. It’s a perfect playground for coding, testing, or homelab fun.</p>
<p>Share your ideas or comments with me – I’d love to hear them!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Set Up a Proxmox Cluster for Free – Virtualization Basics ]]>
                </title>
                <description>
                    <![CDATA[ Virtualization is a game-changer for developers, hobbyists, and IT enthusiasts. It lets you run multiple operating systems on one machine, which is perfect for testing apps, hosting servers, or learning new tech. If you want to take it further, clust... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/set-up-a-proxmox-cluster-virtualization-basics/</link>
                <guid isPermaLink="false">67fd1282e4687cd6aa7dcd1e</guid>
                
                    <category>
                        <![CDATA[ proxmox ]]>
                    </category>
                
                    <category>
                        <![CDATA[ clustering ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtualization ]]>
                    </category>
                
                    <category>
                        <![CDATA[ KVM ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Shamsuddoha Ranju ]]>
                </dc:creator>
                <pubDate>Mon, 14 Apr 2025 13:49:54 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1744488492225/62339e66-50ae-4546-8845-f5c86c415511.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Virtualization is a game-changer for developers, hobbyists, and IT enthusiasts. It lets you run multiple operating systems on one machine, which is perfect for testing apps, hosting servers, or learning new tech. If you want to take it further, clustering ties multiple machines together for more power and flexibility. And you can use Proxmox Virtual Environment (VE) to build a cluster for free – no expensive licenses required.</p>
<p>In this tutorial, you’ll set up a 3-node Proxmox cluster using three computers (or virtual machines for practice). By the end, you’ll have a working cluster ready to host virtual machines (VMs) and experiment with cool features like guest migration and VM replication etc.</p>
<p>Let’s dive in!</p>
<h2 id="heading-prerequisites-what-youll-need-to-know">Prerequisites: What You’ll Need to Know</h2>
<p>This guide is beginner-friendly for clustering, but you’ll need some basic skills to follow along. You should be comfortable with:</p>
<ul>
<li><p>Installing an OS from a USB drive (don’t worry, I’ll walk you through the steps).</p>
</li>
<li><p>Using a terminal for simple commands like <code>ping</code> or <code>nano</code>.</p>
</li>
<li><p>Setting up a home network with static IPs (for example, knowing your router’s IP range). No advanced virtualization or clustering experience is required—I’ll explain the key concepts as we go.</p>
</li>
</ul>
<h2 id="heading-what-youll-need">What You’ll Need</h2>
<ul>
<li><p><strong>Three computers (or VMs):</strong> Start with at least 8GB RAM and 100GB storage per machine, plus a virtualization-capable CPU (most modern ones work). These specs are a baseline—actual RAM and storage depend on how many VMs you want to host (e.g., more VMs need more resources).</p>
</li>
<li><p><strong>Proxmox VE:</strong> Free and open-source. Grab the ISO from <a target="_blank" href="http://proxmox.com">proxmox.com</a>.</p>
</li>
<li><p><strong>Network connection:</strong> All three must be on the same network and be able to ping each other.</p>
</li>
<li><p><strong>A web browser:</strong> For Proxmox’s web interface.</p>
</li>
<li><p><strong>30–60 minutes</strong>: Depending on your setup pace.</p>
</li>
</ul>
<h2 id="heading-why-proxmox-and-clustering">Why Proxmox and Clustering?</h2>
<p>Proxmox VE is a free, open-source virtualization platform built on Debian Linux. It uses KVM for VMs (fully virtualized systems) and LXC for containers (lightweight app environments), all managed via a slick web interface.</p>
<p>Clustering means linking multiple Proxmox machines—called nodes—so they act as one system. Think of it like a team: each node shares the workload, and you control them from a single dashboard. This setup lets you move (migrate) VMs between nodes, boost reliability, and experiment with high availability (HA)—where VMs auto-restart (on healthy node) if a node fails.</p>
<p>Plus, Proxmox offers a handy replication feature: it can sync VM data between nodes automatically, keeping backups ready if something goes wrong.</p>
<p>It’s a must-have skill for DevOps, app testing, or IT tinkering.</p>
<h2 id="heading-2-nodes-vs-3-nodes-which-should-you-choose">2 Nodes vs. 3 Nodes: Which Should You Choose?</h2>
<p>Before we build your 3-node cluster, let’s explore your options. Clustering can start with 2 nodes or go to 3 (or more). Here’s why you might pick one over the other:</p>
<ul>
<li><p><strong>2-Node Cluster</strong>:</p>
<ul>
<li><p><strong>Pros</strong>: Easier setup with just two machines. Great for learning basics or small projects. Uses less hardware.</p>
</li>
<li><p><strong>Cons</strong>: No quorum—a voting majority to keep the cluster running if a node fails—so HA isn’t reliable. You’d need an extra trick (like a quorum device) to avoid stalling.</p>
</li>
<li><p><strong>Best For</strong>: Learning, Testing clustering, or limited resources.</p>
</li>
</ul>
</li>
<li><p><strong>3-Node Cluster</strong>:</p>
<ul>
<li><p><strong>Pros</strong>: Built-in quorum—two out of three nodes keep things going if one crashes. Ideal for HA practice. More stable and scalable.</p>
</li>
<li><p><strong>Cons</strong>: Needs an extra machine and a bit more setup time.</p>
</li>
<li><p><strong>Best For</strong>: Serious learners or small production setups.</p>
</li>
</ul>
</li>
</ul>
<p>We’ll go with 3 nodes—it’s the sweet spot for stability and real-world skills.</p>
<h2 id="heading-step-1-install-proxmox-ve-on-all-three-machines">Step 1: Install Proxmox VE on All Three Machines</h2>
<p>First, download the Proxmox VE ISO from <a target="_blank" href="http://proxmox.com">proxmox.com</a>. Make a bootable USB with Rufus (Windows), <code>dd</code> (Linux/macOS), or Raspberry Pi Imager (available for all platforms).</p>
<p>For <code>dd</code>, use this command (replace placeholders with your ISO and USB device):</p>
<pre><code class="lang-plaintext">sudo dd if=proxmox-ve.iso of=/dev/sdX bs=1M status=progress oflag=sync
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744492694669/777f8642-67dd-4f5f-8e78-b98c0d77ccca.png" alt="Proxmox VE installer screen showing target disk for storage configuration." class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>Boot each machine from the USB and follow the installer. Stick with the default partitioning scheme (it uses EXT4 filesystem) and set static IPs and hostnames as follows (or you can use your own IPs knowing your router’s IP range):</p>
<ul>
<li><p>Node 1: <code>172.20.1.101</code> [hostname: <code>node01.local</code>]</p>
</li>
<li><p>Node 2: <code>172.20.1.102</code> [hostname: <code>node02.local</code>]</p>
</li>
<li><p>Node 3: <code>172.20.1.103</code> [hostname: <code>node03.local</code>]</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744491592723/4b793ada-e21a-4da1-92f1-dd05ad130980.png" alt="Proxmox VE installer screen showing network configuration with hostname and IP entered for Node 1." class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>After installation, each node displays its IP on the console (for example, <a target="_blank" href="https://192.168.10.101:8006">https://172.20.1.101:8006</a>). Test it by opening a browser, visiting each IP, and logging in with root and your password. You’ll see the Proxmox dashboard.</p>
<h2 id="heading-step-2-prepare-your-nodes">Step 2: Prepare Your Nodes</h2>
<p>Now, let’s get your nodes ready to talk to each other—a crucial step for clustering. Without this, they won’t recognize each other properly.</p>
<p>Update <code>/etc/hosts</code> on all three nodes to map IPs to hostnames (since we’re not using a DNS server). Open the file with:</p>
<p><code>nano /etc/hosts</code></p>
<p>Add these lines (IPs and hostnames) on each node:</p>
<pre><code class="lang-plaintext">172.20.1.101 node01.local node01
172.20.1.102 node02.local node02
172.20.1.103 node03.local node03
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744492087833/bb9cb873-f107-4fcd-b53f-25408531975e.png" alt="Terminal window displaying /etc/hosts file in nano editor with IP and hostname entries for three Proxmox nodes." class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>Save and exit (<code>Ctrl+O</code>, <code>Enter</code>, <code>Ctrl+X</code>). This ensures nodes can resolve each other’s names (for example, node01 pings node02.local).</p>
<p>Next, check connectivity. From Node 1’s console (or SSH), ping the others:</p>
<p><code>ping 172.20.1.102</code></p>
<p><code>ping 172.20.1.103</code></p>
<p>Repeat from Node 2 and Node 3. If pings fail, check your network or firewall.</p>
<p>Finally, sync their clocks—clusters need precise time to coordinate. On each node, run:</p>
<p><code>ntpdate pool.ntp.org</code></p>
<p>All three nodes are now primed for clustering.</p>
<h2 id="heading-step-3-create-the-cluster-on-node-1">Step 3: Create the Cluster on Node 1</h2>
<p>Let’s set up the cluster starting with Node 1. Log into its web interface at <a target="_blank" href="https://192.168.10.101:8006">https://172.20.1.101:8006</a>. On the left sidebar, click Datacenter, then Cluster. Hit the Create Cluster button, and a dialog pops up. Name your cluster—let’s call it <strong>MyCluster</strong> and click Create. A task window will appear, showing the process. Wait a few seconds until you see “TASK OK”—that means your cluster is live and Node 1 is its first member. Now we can add the other nodes!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744493528337/b5fb8aa1-e9b6-4028-b129-10d2c665f1b5.png" alt="Proxmox web interface showing the Create Cluster dialog with ‘MyCluster’ entered." class="image--center mx-auto" width="1321" height="705" loading="lazy"></p>
<h2 id="heading-step-4-join-node-2-and-node-3-to-the-cluster">Step 4: Join Node 2 and Node 3 to the Cluster</h2>
<p>With the cluster created, let’s bring in Node 2 and Node 3. On Node 1’s cluster page, click Join Information, then Copy Information—this copies a key you’ll need.</p>
<p>Open Node 2’s web interface (<a target="_blank" href="https://192.168.10.102:8006">https://172.20.1.102:8006</a>), go to Datacenter &gt; Cluster &gt; Join Cluster, paste the key into the Information field, enter Node 1’s root password, and click Join <strong>MyCluster</strong>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744494140010/d1f60b51-480c-44f1-84a1-bb37f79b6bc7.png" alt="Proxmox web interface showing the Join Cluster dialog with ‘join information’ entered." class="image--center mx-auto" width="1315" height="702" loading="lazy"></p>
<p>Repeat this process on Node 3’s interface (<a target="_blank" href="https://192.168.10.103:8006">https://172.20.1.103:8006</a>). Refresh Node 1’s dashboard—under Datacenter, you’ll see all three nodes with green checkmarks.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744495739410/4ce5c263-318d-4a21-94f4-324d30b0fc94.png" alt="Proxmox web interface displaying the Datacenter view with three nodes (node01, node02, node03) showing green status icons." class="image--center mx-auto" width="1317" height="707" loading="lazy"></p>
<p>Your 3-node cluster is up!</p>
<h2 id="heading-step-5-test-your-cluster">Step 5: Test Your Cluster</h2>
<p>Let’s verify it works by creating and moving a test VM. On Node 1, click Create VM, name it TestVM, skip the ISO, and finish with defaults (no disk content needed). Hit the Start button to boot it up.</p>
<p>Now, let’s migrate it around—migration means moving the VM from one node to another to test your cluster’s flexibility. Right-click TestVM, select Migrate, choose Node 2, and click Migrate. The VM stops briefly, copies to Node 2, and restarts (normal without shared storage).</p>
<p>Repeat this, migrating it from Node 2 to Node 3. If it hops between nodes successfully, your cluster’s rocking! With three nodes, you’ve got quorum—try shutting down Node 3 to see the others stay active.</p>
<h2 id="heading-whats-next">What’s Next?</h2>
<p>You’ve built a 3-node Proxmox cluster for free—congrats! Take it further with:</p>
<ul>
<li><p><strong>Shared storage</strong>: Add NFS or a spare drive for live VM migration (no stopping/shutdown needed).</p>
</li>
<li><p><strong>High Availability</strong>: Enable HA—VMs auto-restart on a healthy node if one fails.</p>
</li>
<li><p><strong>VM Replication:</strong> Configure Replication—Sync VM data between nodes automatically, keeping backups ready if something goes wrong.</p>
</li>
<li><p><strong>Scale up</strong>: Add more nodes or try LXC containers.</p>
</li>
</ul>
<p>Check your cluster’s health anytime (from console) with:</p>
<p><code>pvecm status</code></p>
<h2 id="heading-wrapping-up">Wrapping Up</h2>
<p>You’ve just set up a 3-node Proxmox cluster at no cost. It’s a playground for virtualization, DevOps practice, or even hosting small projects. Share your thoughts with me – I’d love to hear how you liked it.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ VM Data Protection Best Practices: How to Mitigate Risk in a Virtual Environment ]]>
                </title>
                <description>
                    <![CDATA[ Vast amounts of data flow through virtualized environments these days. And that data needs to be protected. So making sure that your virtual machines are secured, along with their associated data, is key for maintaining operational continuity and saf... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/vm-data-protection-best-practices/</link>
                <guid isPermaLink="false">66bf49af410af52542e93140</guid>
                
                    <category>
                        <![CDATA[ Data security ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtualization ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtual machine ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Data Protection ]]>
                    </category>
                
                    <category>
                        <![CDATA[ risk management ]]>
                    </category>
                
                    <category>
                        <![CDATA[ proxmox ]]>
                    </category>
                
                    <category>
                        <![CDATA[ vmware ]]>
                    </category>
                
                    <category>
                        <![CDATA[ risk mitigation ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Risk Assessment ]]>
                    </category>
                
                    <category>
                        <![CDATA[ vm ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Alex Tray ]]>
                </dc:creator>
                <pubDate>Fri, 16 Aug 2024 12:44:31 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1723559872911/f9953e98-7948-47a0-a054-62028df854b9.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Vast amounts of data flow through virtualized environments these days. And that data needs to be protected. So making sure that your virtual machines are secured, along with their associated data, is key for maintaining operational continuity and safeguarding against cyber threats.</p>
<p>In this guide, you'll learn about VM-specific risks for data and workloads. I'll also provide some recommendations that can help you mitigate them. Implementing these data protection best practices can help you ensure production continuity, data availability, and regulatory compliance for your organization.</p>
<p><strong>Table of Contents</strong></p>
<dl>
<ul>
  <li><a href="#heading-two-of-the-main-players-vmware-and-proxmox">Two of the Main Players: VMWare and Proxmox</a></li>
  <li><a href="#heading-understanding-the-risks-of-virtual-environments">Understanding the Risks of Virtual Environments</a></li>
  <li>
    <a href="#heading-specific-risks-associated-with-virtual-environments">Specific Risks Associated with Virtual Environments</a>
    <ul>
      <li><a href="#heading-hypervisor-security-vulnerabilities">Hypervisor security vulnerabilities</a></li>
      <li><a href="#heading-vm-sprawl">VM sprawl</a></li>
      <li><a href="#heading-insecure-vm-configurations">Insecure VM configurations</a></li>
      <li><a href="#heading-snapshot-and-clone-risks">Snapshot and clone risks</a></li>
    </ul>
  </li>
  <li>
    <a href="#heading-vm-data-protection-and-secure-virtualization-best-practices">VM Data Protection and Secure Virtualization Best Practices</a>
    <ul>
      <li><a href="#heading-secure-the-virtualized-environment">Secure the Virtualized Environment</a></li>
      <li><a href="#heading-backup-and-recovery-strategies">Backup and Recovery Strategies</a></li>
      <li><a href="#heading-monitoring-and-auditing">Monitoring and Auditing</a></li>
    </ul>
  </li>
  <li>
    <a href="#heading-advanced-protection-techniques">Advanced Protection Techniques</a>
    <ul>
      <li><a href="#heading-encryption">Encryption</a></li>
      <li><a href="#heading-intrusion-detection-and-prevention-systems-idps">Intrusion Detection and Prevention Systems (IDPS)</a></li>
      <li><a href="#heading-application-and-network-security">Application and Network Security</a></li>
    </ul>
  </li></ul></dl>

<h2 id="heading-two-of-the-main-players-vmware-and-proxmox">Two of the Main Players: VMWare and Proxmox</h2>
<p>Both VMware and Proxmox offer robust solutions for virtualization, but they come with their own set of challenges and risks that can impact VM data protection.</p>
<p>VMware is the market leader in virtualization <a target="_blank" href="https://www.6sense.com/tech/virtualization/vmware-market-share#:~:text=VMware%20has%20market%20share%20of,ESXi%20with%205.99%25%20market%20share.">with almost 50% of the market share</a>, which is both a boon and a bane.</p>
<p>On the one hand, VMware has a high-end, efficient portfolio of solutions to build IT environments of any complexity and size. On the other, such popularity means that malicious actors know what they can target during cyberattacks, posing challenges in virtualization security for VMware users.</p>
<p>Proxmox, a prominent alternative to VMware, also offers robust virtualization solutions. While Proxmox may have a smaller market share compared to VMware, it provides a comprehensive set of tools for managing virtual environments. It can also be a good choice for those looking for open-source solutions with flexibility and cost-efficiency.</p>
<p>Over three-quarters of organizations that have 50+ workers <a target="_blank" href="https://smartprofile.io/analytics-papers/vmware-far-largest-server-virtualisation-market/">use server virtualization</a>. So it's hard to overestimate the importance of the data that's circulating in their virtualized workloads.</p>
<p>The workloads themselves can be mission-critical and cause global disruption and downtime in case of failures. The data can also be crucial to run efficient services and generate revenue or be subject to compliance requirements.</p>
<h2 id="heading-understanding-the-risks-of-virtual-environments">Understanding the Risks of Virtual Environments</h2>
<p>Before we proceed with VM security best practices, let’s go over some general security issues associated with virtual environments.</p>
<ul>
<li><p><strong>Data breaches</strong> are a regular issue that most IT protection systems experience. A lone hacker or an organized cybercriminal group can intrude into corporate environments to steal data. Their targets are typically clients' personal data, credit card info, credentials, and intellectual property.</p>
</li>
<li><p><strong>Insider threats</strong> are usually the most underrated yet <a target="_blank" href="https://www.ekransystem.com/en/blog/insider-threat-statistics-facts-and-figures">exceptionally dangerous issue</a>. Malicious insiders sneakily strike from the inside of an organization’s security perimeter and may have advanced access privileges. This can lead to a global IT disaster, and preventing it is a high-level challenge.</p>
</li>
<li><p><strong>Malware and ransomware attacks</strong> are an ever-evolving threat for organizations of all sizes and types.</p>
</li>
<li><p><strong>System vulnerabilities and exploits.</strong> The supply chains of today’s IT services can be complicated and consist of multiple synchronized solutions. Every solution involved in service provisioning is a potential source of vulnerabilities that malicious actors can exploit upon discovery.</p>
</li>
</ul>
<h2 id="heading-specific-risks-associated-with-virtual-environments">Specific Risks Associated with Virtual Environments</h2>
<p>Understanding the risks of virtualization – particularly with VMware, one of the most popular virtualization platforms for enterprises, and Proxmox, which has seen increasing adoption in recent times – will help you and your team build an effective data protection system in your virtualized environments.</p>
<p>The unique threats associated with these platforms dictate how you should secure your virtual machines, servers, networks, and other virtualized nodes.</p>
<p>Key factors that can weaken virtualized infrastructure security include:</p>
<h3 id="heading-hypervisor-security-vulnerabilities"><strong>Hypervisor security vulnerabilities</strong></h3>
<ul>
<li><p><strong>VMware</strong>: Because of its extensive use in enterprises, attackers frequently target VMware. Major issues can arise due to the integration and complexity of VMware's hypervisor. The "<a target="_blank" href="https://www.nakivo.com/blog/vmware-esxi-ransomware/?utm_source=Freecodecamp&amp;utm_medium=guest_post&amp;utm_campaign=free_trial">ESXiArgs</a>" ransomware strain takes advantage of VMware vulnerabilities to infiltrate computers before the distribution of updates.</p>
</li>
<li><p><strong>Proxmox</strong>: While this open-source technology does have the potential for hypervisor vulnerabilities, the community can also provide security improvements such as timely patches, vulnerability reports, and enhancements to security protocols. Insufficiently managed upgrades or third-party modules can put Proxmox users at risk of security vulnerabilities.</p>
</li>
</ul>
<h3 id="heading-vm-sprawl"><strong>VM sprawl</strong></h3>
<ul>
<li><p><strong>VMWare:</strong> The ease of deploying VMs in VMware can lead to VM sprawl, where numerous virtual machines are created but not adequately managed. IT teams can create a virtual machine, for example, to test a new feature in an isolated environment before releasing it in production. If not deleted after completing the task, the new virtual machine can remain in an environment without attention, maintenance, or security updates.</p>
</li>
<li><p><strong>Proxmox</strong>: Proxmox's flexibility in managing virtual environments causes VM sprawl, which is more likely to affect smaller teams lacking strong monitoring. Its straightforward interface and streamlined deployment processes help to make creating and managing many virtual machines (VMs) a delight. While this helps with development and testing quickly, it can also cause an influx of virtual machines (VMs) to be launched without proper management or preparation.</p>
</li>
</ul>
<h4 id="heading-insecure-vm-configurations"><strong>Insecure VM configurations</strong></h4>
<ul>
<li><p><strong>VMware</strong>: A VMWare virtual machine itself is a complex environment with multiple configurations and dependencies. Misconfiguration of VMware's resources, operating systems, or applications can lead to additional virtual desktop security risks.</p>
</li>
<li><p><strong>Proxmox</strong>: Users of Proxmox might also face security pitfalls due to misconfigured VMs, especially when utilizing custom templates or third-party integrations. Insufficient security settings can expose services and open ports, enabling unauthorized access.</p>
</li>
</ul>
<h4 id="heading-snapshot-and-clone-risks"><strong>Snapshot and clone risks</strong></h4>
<ul>
<li>Inappropriate VM snapshot retention and maintenance policies in both Proxmox and VMware environments can cause storage overload. Creating too many VM clones can eventually lead to RAM and CPU deficiencies. Insufficiency of hardware resources then causes performance degradation and disk failures, resulting in downtime and data loss.</li>
</ul>
<h2 id="heading-vm-data-protection-and-secure-virtualization-best-practices">VM Data Protection and Secure Virtualization Best Practices</h2>
<p>Data loss in virtualized environments, such as VMWare or Proxmox, can lead to fines, financial losses, and reputational damage for an organization.</p>
<p>Below are some recommendations on how to improve VM data security for virtual nodes, clusters, and infrastructures. The tips cover both virtualization-specific risks and those common to IT security, providing valuable insights for managing data protection effectively in both VMware and Proxmox environments.</p>
<h3 id="heading-secure-the-virtualized-environment">Secure the Virtualized Environment</h3>
<p>For starters, you can strengthen your environment with regular VM security practices. Consider implementing the following:</p>
<h4 id="heading-strong-access-controls-and-authentication-mechanisms"><strong>Strong access controls and authentication mechanisms.</strong></h4>
<p>Role-based access control (RBAC) is an efficient security measure that ensures users have only the access and privileges required to fulfill job duties. With roles set for every employee, their accounts become less dangerous under unauthorized access in case of, for example, compromised credentials.</p>
<p>This can help you either completely counter a security breach attempt or at least significantly mitigate the consequences of a protection failure. Two-factor authentication (2FA) added on top of that purposely complicates the login process, making regular passwords insufficient to hack and exploit an account.</p>
<h4 id="heading-regular-updates-and-patch-management"><strong>Regular updates and patch management</strong></h4>
<p>Set up regular update checks for solutions included in your supply chain. Installing updates and especially security patches on time means that your system closes known vulnerabilities. This reinforces the security perimeter and can protect your environment from random breaches and brute-force attacks, supporting secure virtualization.</p>
<h4 id="heading-network-segmentation-and-isolation"><strong>Network segmentation and isolation</strong></h4>
<p>Combined with external protection reinforcement, segmenting your network using virtual routers, firewalls and switches can be efficient in isolating critical workloads and data from major threats.</p>
<p>A complex internal environment poses an additional challenge for hackers preparing their attacks. Also, if a network scan shows that the infrastructure is ramified and segmented, some bad actors may even conclude that an attack is not worth the effort.</p>
<h3 id="heading-backup-and-recovery-strategies">Backup and Recovery Strategies</h3>
<p>Backups are essential in building an efficient VM data protection system. When all else fails, a backup can help you restore critical data and workloads with little to no downtime.</p>
<p>An efficient VM backup and recovery system includes:</p>
<p><strong>Regular and automated VM backups.</strong> To ensure minimal downtime, you need a backup with a “fresh” recovery point recorded. Given the complexity of even the smallest corporate virtualized environments, only automation and scheduling backups can ensure their regularity.</p>
<p><strong>Offsite and cloud-based backup solutions.</strong> In addition to onsite backups, consider sending data copies to offsite and cloud repositories. This helps you avoid a single point of failure and keep up with the 3-2-1 backup rule.</p>
<p>In case your main infrastructure is down due to a disruption, offsite backups in two different destinations can remain recoverable and accessible.</p>
<p><strong>Disaster recovery planning and testing.</strong> Virtualized environments can include hundreds and thousands of virtual machines, servers and clusters to provide stable and efficient services.</p>
<p>To minimize downtime after global failures, you need to <a target="_blank" href="https://www.nakivo.com/blog/components-disaster-recovery-plan-checklist/">plan disaster recovery</a> (DR) sequences and test them regularly. Set up a scheduled testing workflow to ensure checks.</p>
<p>Also, you might want to conduct disaster recovery testing sessions every time you introduce changes into your main virtualized environment.</p>
<p>Advanced <a target="_blank" href="https://www.cybersecurity-insiders.com/proxmox-backup-by-nakivo-powerful-vm-data-protection/">VM data protection</a> solutions for secure virtualization, such as <a target="_blank" href="https://www.nakivo.com/proxmox-backup/">NAKIVO Backup &amp; Replication</a>, provide the set of features and functions required to implement the above-mentioned VM backup recommendations.</p>
<p>As a regular user of the NAKIVO solution, specifically for protecting virtualized environments, I’ve experienced firsthand the benefits of its robust features. I highly recommend taking advantage of the <a target="_blank" href="https://www.nakivo.com/resources/download/trial-download/?utm_source=Freecodecamp&amp;utm_medium=guest_post&amp;utm_campaign=free_trial">free version</a> of this solution, which is available until the end of 2024.</p>
<h3 id="heading-monitoring-and-auditing">Monitoring and Auditing</h3>
<p>One of the most efficient VM data protection best practices for virtualized environments is to monitor resource usage, VM health, and behavior. This includes the following:</p>
<p><strong>Continuous monitoring of virtualized environments.</strong> Sufficient hardware resources are crucial for production continuity in virtualized environments. You may want to keep track of infrastructures in general and mission-critical VMs in particular. Thus, you can know the current resource consumption and predict scaling needs and budgets to support system stability as your organization grows.</p>
<p><strong>Audit trails and logging.</strong> Audit trails and logging help you get a sequential record of specific activities and data within systems and their components. This includes failed and successful logins, MAC addresses and IPs of involved devices, access locations, data transactions as well as VM and policy changes.</p>
<p><strong>Anomaly detection and response.</strong> With monitoring and logging established and functioning, you can detect anomalies in the behavior of users and VMs, and resource consumption changes within system nodes. With such behavioral data, you can timely react to potential security threats.</p>
<h2 id="heading-advanced-protection-techniques">Advanced Protection Techniques</h2>
<p>Advanced threat protection tips for virtual machines describe techniques related to encryption, intrusion detection and prevention systems, and additional security of applications and networks. Let’s review every technique in detail.</p>
<h3 id="heading-encryption">Encryption</h3>
<p>In a modern IT landscape where any user is able to download and use traffic interception tools, unencrypted data is most likely public data. To enhance your VM data protection for secure virtualization, you can ensure:</p>
<ul>
<li><p><strong>Encrypting data at rest and in transit.</strong> Encrypt data during transmission (in flight) and throughout retention (at rest). Such all-round data encryption enables you to enhance protection from unauthorized access in most situations.</p>
</li>
<li><p><strong>Implementing secure key management.</strong> For additional security, consider setting up an encryption key management system. This includes regular generation, secure exchange, storage and use, timely destruction and replacement of encryption keys.</p>
</li>
</ul>
<h3 id="heading-intrusion-detection-and-prevention-systems-idps">Intrusion Detection and Prevention Systems (IDPS)</h3>
<p>Intrusion detection and prevention systems are designed to scan and monitor networks and automatically take action to counter possible breaches.</p>
<ul>
<li><p><strong>Integrating IDPS with VMs.</strong> IDPS integration is about revealing the key nodes of your virtual environment and installing program “sensors” that track the situation around them. You can then count on software automation to take the first actions to counter possible intrusions as they occur.</p>
</li>
<li><p><strong>Real-time threat detection and response.</strong> Consider developing specialized workflows for responding to intrusions after the IDPS detects them and stops the most obvious malicious activities. Keep in mind that modern cyberattacks can involve a multi-layered series of smaller hits to distract and deceive the defenders.</p>
</li>
</ul>
<h3 id="heading-application-and-network-security">Application and Network Security</h3>
<p>In addition to supply chain control, network segmentation, and isolation, you can make your VM data protection system more reliable with additional app and network security enhancements. For instance, consider the following steps:</p>
<ul>
<li><p><strong>Hardening VM applications.</strong> As apps can become weak links in your protection chain, consider hardening their protection. For example, remove unnecessary components and disable unwanted services that such applications might run. Also, you can set reliable passwords, regular code reviews and role-based access controls within apps.</p>
</li>
<li><p><strong>Implementing firewall and VPN solutions.</strong> These are additional VM data protection best practices that specifically harden networks. External and internal firewalls can prevent unauthorized access to system elements, while VPN connections ensure secure access for authorized users.</p>
</li>
</ul>
<h2 id="heading-future-trends-in-vm-data-protection">Future Trends in VM Data Protection</h2>
<p>The future of secure virtualization mainly depends on the evolution of relevant threats. The popularity of virtualization solutions, such as VMWare and Proxmox, defines the close attention that hackers pay to VM vulnerabilities and specifics.</p>
<p>Malicious actors also shape their ransomware, interception, and intrusion tools to become more dangerous to virtualized IT infrastructure. Sophisticated malware enables deeply customized attacks that exploit the VM security weaknesses of the organization’s infrastructure.</p>
<p>The improvement of AI algorithms can bring additional challenges to the field, making malware spread faster, becoming less detectable, and targeting priority nodes with efficient strikes.</p>
<p>However, the same idea works for VM security best practices. AI-driven cyber defense solutions can help detect and counter specific threats in VM environments with significantly better performance and efficiency.</p>
<p>Advanced VM threat detection based on behavioral analysis throughout the entire infrastructure can help reveal malware earlier. Prevention tools independently reacting to potentially dangerous changes in an environment can enable quick response and counter cyberattacks right after they begin.</p>
<p>Lastly, AI can learn how to enhance protection flexibility and introduce defensive changes in an environment depending on how a cyberattack develops. The boosted speed and variety of <a target="_blank" href="https://www.hostpapa.com/blog/web-hosting/what-small-businesses-need-to-know-about-cybersecurity/">cybersecurity</a> moves then promote virtualized security (and data protection as a whole) to notably higher effectiveness levels.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Thorough VM security is crucial for any organization that's using virtualized IT environments. Consider implementing strong access controls, patch management, network segmentation, monitoring, auditing and app security to counter key threats and mitigate their outcomes.</p>
<p>You might also want to build an advanced <a target="_blank" href="https://www.nakivo.com/blog/proxmox-backup/">Proxmox replication</a> or <a target="_blank" href="https://www.nakivo.com/blog/vmware-backup/">VMware backup</a> system to have a swift data recovery option in case of a breach or system failure.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Secure Your Container Deployments with Chainguard ]]>
                </title>
                <description>
                    <![CDATA[ You don't need to convince me that containers are absolutely the best thing to come out of the virtualization revolution. I use containers of one flavor or another just about every day.  But the beauty of template-it-once-and-deploy-it-everywhere com... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/secure-container-deployment-with-chainguard/</link>
                <guid isPermaLink="false">66b9962da3099de4654e61b2</guid>
                
                    <category>
                        <![CDATA[ containers ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Security ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtualization ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ David Clinton ]]>
                </dc:creator>
                <pubDate>Fri, 05 Apr 2024 01:46:19 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2024/04/frank-mckenna-tjX_sniNzgQ-unsplash.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>You don't need to convince me that containers are absolutely the best thing to come out of the virtualization revolution. I use containers of one flavor or another just about every day. </p>
<p>But the beauty of template-it-once-and-deploy-it-everywhere comes with a cost: what if a single layer within that template contains a security vulnerability? And if there was a vulnerability tucked away down there, how would you even know? </p>
<p>In this article, I'll to show you how to use Chainguard (and Docker Scout) to manage security for all your images.</p>
<p>You can watch the video version of this article here:</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/ao1Upn3Yooo" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<p>When you build your software infrastructure on a physical server the traditional way, you'll manually acquire and install each element of the stack one piece at a time. The odds are that you'll be pulling the latest version of everything straight from the official source. And you'll at the very least be thinking about each layer. </p>
<p>But most modern containers are built from complicated templates. It's easy to just copy and paste the code and fire it up. It's very possible that you might not even be <em>aware</em> of all the software that's powering your application. And even if you are, it would easily take you hours of research into each and every element to figure out where you stand.</p>
<p>That's the problem that <a target="_blank" href="https://www.chainguard.dev/">Chainguard</a> exists to solve. Chainguard provides <a target="_blank" href="https://images.chainguard.dev/?category=featured">hundreds of well-maintained custom versions of many of the most popular container images out there</a>. </p>
<p>Of course, you're free to pull, say, the official MariaDB image into your Dockerfile, but going with the Chainguard version instead will be a far safer choice. That's because Chainguard is constantly analyzing their image layers for vulnerabilities and building images that are as up-to-date and secure as possible.</p>
<p>Let's find out how all of this actually works in the real world. Before we get started with building new images, I should tell you how we're going to visualize each image's vulnerabilities so we can quantify the Chainguard advantage. </p>
<p>First though, I should explain that infrastructure vulnerabilities are generally defined using the <a target="_blank" href="https://www.cve.org/">Common Vulnerabilities and Exposures – or CVE – system</a> based on the National Vulnerability Database maintained by the US government's NIST. There are hundreds of thousands of CVE definitions that have been identified and categorized by the CVE system, with each one rated by severity. The existence of this database – along with a number of important related tools – allows us to automate our security assessments. </p>
<p>Docker Scout is one of those tools. <a target="_blank" href="https://docs.docker.com/scout/install/">This page</a> gives you installation instructions for using Scout on Docker Engine, but it should run out of the box if you're using Docker Desktop. The <code>curl</code> command will simply download the <code>install-scout</code> Bash script that'll make everything happen.</p>
<pre><code class="lang-bash">curl -fsSL https://raw.githubusercontent.com/docker/scout-cli/main install.sh -o install-scout.sh
</code></pre>
<h2 id="heading-how-to-choose-the-right-image">How to Choose the Right Image</h2>
<p>I created a Dockerfile that'll pull the official MariaDB image from Docker Hub:</p>
<pre><code>FROM mariadb:latest

ENV MYSQL_ROOT_PASSWORD=my_root_password
ENV MYSQL_DATABASE=my_database

ENV MYSQL_USER=my_user
ENV MYSQL_PASSWORD=my_user_password
</code></pre><p>We'll pretend that the image will be used for a multi-tiered deployment, so we'll create a root database and password, and a new user account with it's own password. There might be an application tier instance that'll use those credentials to access the database at some point. </p>
<p>Either way, I'll build the image the usual way, giving it the name <code>mariadb_standard</code>. </p>
<pre><code>docker build -t mariadb_standard .
</code></pre><p>There's another Dockerfile that's exactly the same as the first one, except that we're pulling the special Chainguard image of MariaDB. </p>
<pre><code>
FROM chainguard/mariadb

ENV MYSQL_ROOT_PASSWORD=my_root_password
ENV MYSQL_DATABASE=my_database

ENV MYSQL_USER=my_user
ENV MYSQL_PASSWORD=my_user_password
</code></pre><p>That image came from Docker Hub, but we could have just as easily pulled it from Chainguard's own repo:</p>
<pre><code>docker pull cgr.dev/chainguard/mariadb:latest
</code></pre><p>Build this image the same way you did for the official image.  When you scan the two images, here's what you'll see:</p>
<pre><code>$ docker images
REPOSITORY         TAG       IMAGE ID       CREATED       SIZE
mariadb_cg         latest    <span class="hljs-number">50</span>a484d1ded3   <span class="hljs-number">7</span> days ago    <span class="hljs-number">556</span>MB
mariadb_standard   latest    <span class="hljs-number">67949</span>ccf8eb5   <span class="hljs-number">6</span> weeks ago   <span class="hljs-number">405</span>MB
</code></pre><p>The Chainguard image is, as you can see, quite larger. But note how it's actually a whole lot more recent. </p>
<h2 id="heading-how-to-scan-your-image">How to Scan Your Image</h2>
<p>Now it's time to put <code>docker scout</code> to work. Here's how that'll work. I'll point Scout to the <code>mariadb_standard</code> image first:</p>
<pre><code>$ docker scout qv mariadb_standard
</code></pre><p><code>qv</code>, by the way, is short for <code>quickview</code>. </p>
<p>Here's what the output should look like:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/04/scan1.png" alt="Image" width="600" height="400" loading="lazy">
<em>docker scout output</em></p>
<p>The standard image is made up of three layers, beginning with the Ubuntu 23.10, then Ubuntu 22.04 long term support release, and then MariaDB on top. Ubuntu has 10 Low and 9 Medium vulnerabilities. Alarmingly, the MariaDB layer has 2 Critical and 28 High problems. </p>
<p>This should be enough to keep an admin up at night. And sorting through all of those to figure out which are show stoppers and which aren't such a big deal for your environment will take you a lot of time.</p>
<p>Now I'll run Scout against the Chainguard image: </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/04/scan2.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>First off, we can see that there's only one layer here. I suspect that's one way that Chainguard maintains control over their images. Those two Critical vulnerabilities are still there, but there are only 5 High severity and no Medium or Low at all. </p>
<p>If you wanted, you could dive deeper to display all the individual vulnerabilities. Here's the command to do that with an excerpt of the output:</p>
<pre><code>$ docker scout cves local:<span class="hljs-comment">//mariadb_cg</span>
    ✗ CRITICAL GHSA-xfg6<span class="hljs-number">-62</span>px-cxc2 [OWASP Top Ten <span class="hljs-number">2017</span> Category A9 - Using Components <span class="hljs-keyword">with</span> Known Vulnerabilities]
      <span class="hljs-attr">https</span>:<span class="hljs-comment">//scout.docker.com/v/GHSA-xfg6-62px-cxc2</span>
      Affected range : &lt;42.2.8                                         
      Fixed version  : 42.7.2, 42.6.1, 42.5.5, 42.4.4, 42.3.9, 42.2.8  
      CVSS Score     : 10.0                                            
      CVSS Vector    : CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H    

    ✗ CRITICAL CVE-2024-1597 [Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')]
      https://scout.docker.com/v/CVE-2024-1597
      Affected range : &lt;42.2.28                                      
      Fixed version  : 42.2.28                                       
      CVSS Score     : 10.0                                          
      CVSS Vector    : CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H
</code></pre><p>We can research each of those using the standard CVE tools and databases to understand them better. But it'll be a whole lot easier than it would have been researching all 28 High severity vulnerabilities in the standard MariaDB image.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>So if you're worried about container image security – and you'd better be – then Docker Scout is an excellent tool for maintaining visibility in your stacks. And Chainguard's cleaner images can give you a significant head start.</p>
<p><em>There's more IT goodness in the form of books, courses, and videos available at <a target="_blank" href="https://bootstrap-it.com">my Bootstrap IT site</a>.</em></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How Docker Containers Work – Explained for Beginners ]]>
                </title>
                <description>
                    <![CDATA[ A container is a lightweight, standalone, and executable software package that includes everything needed to run a piece of software. And one of the most popular tools for working with containers is Docker. Docker is both the name of the company (Doc... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-docker-containers-work/</link>
                <guid isPermaLink="false">66d45e144a7504b7409c336a</guid>
                
                    <category>
                        <![CDATA[ containers ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Docker ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Docker Containers ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtual machine ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtualization ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Daniel Adetunji ]]>
                </dc:creator>
                <pubDate>Mon, 23 Oct 2023 16:45:13 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/10/cover-final.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>A container is a lightweight, standalone, and executable software package that includes everything needed to run a piece of software.</p>
<p>And one of the most popular tools for working with containers is Docker.</p>
<p>Docker is both the name of the company (Docker Inc) and the software they have created which packages software into containers.</p>
<p>To understand how containers work and why they are incredibly useful for software development, you need to understand two seemingly unrelated topics – shipping containers and virtual machines.</p>
<h2 id="heading-a-brief-history-of-shipping-containers">A Brief History of Shipping Containers</h2>
<p>"The Box: How the Shipping Container Made the World Smaller and the World Economy Bigger" is a book by <a target="_blank" href="https://www.amazon.co.uk/Box-Shipping-Container-Smaller-Economy/dp/0691170819/ref=sr_1_1?crid=14VL4VEQHDVNL&amp;keywords=the+box+book&amp;qid=1694037660&amp;sprefix=the+box+book%2Caps%2C97&amp;sr=8-1">Marc Levinson</a>. It explores the profound impact of the shipping container on global trade and the world economy.</p>
<p>While the history of the shipping container may seem irrelevant in a discussion about Docker containers, they have more in common than you would expect.</p>
<p>Before shipping containers, cargo handling was labor-intensive and time-consuming, leading to inefficiencies and delays in global trade. Cargo arrived in various shapes and sizes, and the lack of standardised packaging made it challenging to stack and secure items efficiently.</p>
<p>Without standardised containers, cargo was often stored haphazardly in the holds of ships or in dockyards. This inefficient use of space meant that ships were not carrying as much cargo as they could potentially hold, leading to higher transportation costs.</p>
<p>The adoption of uniform container dimensions and handling procedures allowed for seamless transfer of cargo between different modes of transportation – ships, trucks, trains, and the cranes used to move the containers around.</p>
<p><img src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ac7826e-ebd0-4062-8f49-d48a6f9ef9ce_1886x946.png" alt="Image" width="1456" height="730" loading="lazy"></p>
<p><em>Image showing how standardised container sizes allow them to be easily moved between ships, trains and trucks.</em></p>
<p>This standardisation was the key to the success of shipping containers. After all, if one company’s containers didn't fit on another company's ship, truck, or freight train, they couldn't be properly transported. Every company would need its own fleet of containers to be able to send things to each of their customers – which would be an operational nightmare.</p>
<p>Standardisation of shipping containers makes them portable, that is easy to move from one place to another. This portability is a key feature of Docker containers as well, which we'll discuss shortly.</p>
<h2 id="heading-what-are-virtual-machines">What are Virtual Machines?</h2>
<p>Virtual machines (VMs) are created through a process called virtualisation.</p>
<p>Virtualisation is a technology that allows you to create multiple simulated environments or virtual versions of something, such as an operating system, a server, storage, or a network, on a single physical machine.</p>
<p>These virtual environments behave as if they are independent, separate entities, even though they share the resources of the underlying physical system.</p>
<p>Virtualisation is like having a magician's hat that can conjure up multiple hats within it. Just as the magician's hat creates the illusion of many hats appearing from just a single physical hat, virtualisation allows a single physical computer or server to appear as multiple virtual machines (VMs), each with its own operating system and resources.</p>
<p>VMs virtualise the hardware. This simply means that a VM takes a single piece of hardware – a server – and creates virtual versions of other servers running their own operating systems. Physically, it is just a single piece of hardware.</p>
<p>Logically, multiple virtual machines can run on top of a single piece of hardware. This is essentially one or more computers running within a computer, as shown below.</p>
<p><img src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9733d44-d0c7-49e6-8978-da253cf9c3a9_1650x966.png" alt="Image" width="1456" height="852" loading="lazy"></p>
<p><em>Image showing how virtualisation creates several virtual machines (VMs) from a single physical server</em></p>
<h3 id="heading-how-does-virtualisation-work">How does virtualisation work?</h3>
<p>So you might be wondering – how exactly does virtualisation work? Have a look at the image below:</p>
<p><img src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cd74b32-e3d1-430f-bbd6-e0daf2150b82_1084x576.png" alt="Image" width="1084" height="576" loading="lazy"></p>
<p><em>Image showing how virtualisation works by virtualising a single piece of hardware to create multiple virtual machines</em></p>
<p>At the base, you have the host hardware and OS. This is the physical machine that is used to create the virtual machines. On top of this, you have the hypervisor. This allows multiple virtual machines, each with their own operating systems (OS), to run on a single physical server.</p>
<p>VMs have a few downsides, though, which containers address. Two downsides particularly stand out:</p>
<ol>
<li><p>VMs consume more resources: VMs have a higher resource overhead due to the need to run a full OS instance for each VM. This can lead to larger memory and storage consumption. This in turn can have a negative effect on performance and startup times of the virtual machine.</p>
</li>
<li><p>Portability: VMs are typically less portable due to differences in underlying OS environments. Moving VMs between different hypervisors or cloud providers can be more complex.</p>
</li>
</ol>
<p>The major cloud providers all have VMs. For AWS, it's EC2, GCP has Compute Engine, and Azure has Azure Virtual Machines.</p>
<h2 id="heading-what-are-containers">What are Containers?</h2>
<p>A container is a lightweight, standalone, and executable software package that includes everything needed to run a piece of software, including the code, runtime, system tools, and libraries.</p>
<p>Containers are designed to isolate applications and their dependencies, ensuring that they can run consistently across different environments. Whether the application is running from your computer or in the cloud, the application behaviour remains the same.</p>
<p>Unlike VMs which virtualise the hardware, <a target="_blank" href="https://aws.amazon.com/compare/the-difference-between-containers-and-virtual-machines/#:~:text=Containers%20virtualize%20the%20operating%20system,use%20your%20hardware%20resources%20efficiently.">containers virtualise the operating system</a>. This simply means that a container uses a single OS to create a virtual application and its libraries. Containers run on top of a shared OS provided by the host system.</p>
<p>This is illustrated below:</p>
<p><img src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55e6ff35-1917-4374-8006-80aa8668a772_1160x470.png" alt="Image" width="1160" height="470" loading="lazy"></p>
<p><em>Image showing how containers works by virtualising the OS</em></p>
<p>The container engine allows you to spin up containers. It provides the tools and services necessary for building, running, and deploying containerised applications.</p>
<p>Containers have several benefits:</p>
<ol>
<li><p><strong>Portability</strong>: Containers are designed to be platform-independent. They can run on any system that supports the container runtime, such as Docker, regardless of the underlying operating system. This makes it easier to move applications between different environments, including local development machines, testing servers, and different cloud platforms.</p>
</li>
<li><p><strong>Efficiency</strong>: Containers share the host system's operating system, which reduces the overhead of running a virtual machine with multiple operating systems. This leads to more efficient resource utilization and allows for a higher density of applications that can run on a single host.</p>
</li>
<li><p><strong>Consistency</strong>: Containers package all the necessary components, including the application code, runtime, libraries, and dependencies, into a single unit. This eliminates the "it works on my machine" problem and ensures that the application runs consistently across different environments, from development to production.</p>
</li>
<li><p><strong>Isolation</strong>: Containers provide a lightweight and isolated environment for running applications. Each container encapsulates the application and its dependencies, ensuring that they do not interfere with each other. This isolation helps prevent conflicts and ensures consistent behaviour across different environments.</p>
</li>
<li><p><strong>Fast Deployment</strong>: Containers can be created and started quickly, often in a matter of seconds. This rapid deployment speed is particularly beneficial for applications that need to rapidly scale up or down based on demand.</p>
</li>
</ol>
<h2 id="heading-what-is-docker">What is Docker?</h2>
<p>Now that we have covered VMs and containers, what exactly is Docker? Docker is simply a tool for creating and managing containers.</p>
<p>At its core, Docker has two concepts that are useful to understand: the Dockerfile and Docker Images.</p>
<p>A Dockerfile contains the set of instructions for building a Docker Image.</p>
<p>A Docker Image serves as a template for creating Docker containers. It contains all the necessary code, runtime, system tools, libraries, and settings required to run a software application.</p>
<p>So, a Dockerfile is used to build a Docker Image which is then used as the template for creating one or more Docker containers. This is illustrated below.</p>
<p><img src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f5a703a-0a08-48a0-be54-46ca4a29a9dc_1974x534.png" alt="Image" width="1456" height="394" loading="lazy"></p>
<p><em>Image showing the steps to create a docker container. First you create the Dockerfile which is used to build the Docker Image which is finally used to run a Docker container</em></p>
<p>If this explanation still causes you to scratch your head, consider the following analogy using shipping containers.</p>
<p>Imagine you need to build multiple shipping containers to transport items all over the world. You start with a document listing out the requirements for your shipping container. This will contain information like the container dimensions, type of seals, door locking mechanisms, ventilation and refrigeration requirements (if you are shipping food that needs a temperature controlled environment, for example), and so on.</p>
<p>This requirement document will then be used to create a detailed template for the container which will include engineering drawings showing the dimensions and other specifications.</p>
<p>From this template, the physical containers will then be built. This single template can be used to build one or many physical containers which will all be identical and match the specifications in the container template.</p>
<p>This is illustrated below:</p>
<p><img src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa1ac249-4fd1-49f2-8b7b-e52914017f89_1944x830.png" alt="Image" width="1456" height="622" loading="lazy"></p>
<p><em>Image showing a shipping container analogue for docker containers</em></p>
<p>The Dockerfile is analogous to the requirements document, which simply has a set of instructions for building the container template.</p>
<p>The Docker Image is analogous to the container template, which details all the instructions needed for building the physical container.</p>
<p>Once created, Docker images are immutable, meaning they cannot be changed. If you need to make changes to an application, you need to modify the Dockerfile and create a new image. This immutability ensures consistency and reproducibility in application deployment.</p>
<p>And finally, the Docker container is analogous to the physical shipping container.</p>
<h2 id="heading-bringing-it-together">Bringing it Together</h2>
<p>In summary, containers provide a <strong>portable</strong> and <strong>efficient</strong> way to package applications and their dependencies, ensuring consistency across various environments. The benefits they bring to software development is similar to the benefits brought to the global economy by the humble shipping container.</p>
<h3 id="heading-portability">Portability</h3>
<p>Shipping containers, through standardisation, ensure that any container, anywhere in the world, can be seamlessly used to move items across various modes of transportation – ships, trucks, trains and the cranes used to load them on and off different forms of transport.</p>
<p>Similarly, Docker containers allow for portability. They ensure that applications can run consistently across different environments, from development laptops to production servers, and across different cloud providers.</p>
<h3 id="heading-increased-efficiency">Increased Efficiency</h3>
<p>With standard container sizes, the packing density of goods you can move increases. Now, you can squeeze more things into a single shipping container, compared to the days before the shipping container existed where you had cargo in non standard shapes and sizes stored haphazardly in the holds of ships or on dockyards. So, every ship, freight train or truck can carry more goods during every trip, making it cheaper to move goods around the world.</p>
<p>With Docker containers, better efficiency comes from the fact that containers share the host operating system, making them lightweight compared to VMs. This leads to rapid container startup times and less CPU, memory, and storage use.</p>
<p>Less resource utilisation also means that containers can increase the application density when compared to VMs. With containers, you can run more applications on the same hardware without a significant drop in performance.</p>
<p>To conclude, the shipping container by itself is not magical. After all, it is just a metal box. It is the standardisation of shipping containers which made them portable and a cheap and efficient way to move goods around the world.</p>
<p>In application development, containers benefit from standardisation in the same way. Containers provide a portable and efficient way to package applications and their dependencies, ensuring consistency across various environments.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Windows Sandbox Tutorial – How to Enable Sandbox On Windows ]]>
                </title>
                <description>
                    <![CDATA[ Windows Sandbox is a temporary lightweight desktop environment that you can use to safely run Windows applications in an isolated space.  The software or applications that you install inside the Windows sandbox environment remain "sandboxed", and the... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-enable-sandbox-on-windows/</link>
                <guid isPermaLink="false">66b902d0626438a622a1ef7d</guid>
                
                    <category>
                        <![CDATA[ virtualization ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Windows ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Md. Fahim Bin Amin ]]>
                </dc:creator>
                <pubDate>Mon, 11 Apr 2022 20:13:55 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/04/close-up-image-programer-working-his-desk-office.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Windows Sandbox is a temporary lightweight desktop environment that you can use to safely run Windows applications in an isolated space. </p>
<p>The software or applications that you install inside the Windows sandbox environment remain "sandboxed", and they all run separately from the host machine. So whatever happens in the sandbox remains there, and your host machine stays 100% safe.</p>
<p>As the Sandbox is a temporary instance of your host machine, when you close it, all of the software, data, files, and the state also get deleted instantly. So you should copy all of the necessary data/software that you'll need later from the sandbox to the host machine before closing it. </p>
<p>Whenever you open the Sandbox, each time you'll get a completely brand-new instance of it. This also means you will get a completely new instance of your host machine that acts as a temporary experiment lab. There you can experiment with any Windows application/data you want, without having the risk of breaking your original host machine.</p>
<p>According to the <a target="_blank" href="https://docs.microsoft.com/en-us/windows/security/threat-protection/windows-sandbox/windows-sandbox-overview">Microsoft Docs</a>,</p>
<blockquote>
<p>Windows Sandbox has the following properties:
<strong>Part of Windows:</strong> Everything required for this feature is included in Windows 10 Pro and Enterprise. There's no need to download a VHD.
<strong>Pristine:</strong> Every time Windows Sandbox runs, it's as clean as a brand-new installation of Windows.
<strong>Disposable:</strong> Nothing persists on the device. Everything is discarded when the user closes the application.
<strong>Secure:</strong> Uses hardware-based virtualization for kernel isolation. It relies on the Microsoft hypervisor to run a separate kernel that isolates Windows Sandbox from the host.
<strong>Efficient:</strong> Uses the integrated kernel scheduler, smart memory management, and virtual GPU.</p>
</blockquote>
<p>💡(Windows Sandbox enables network connection by default. It can be disabled using the <a target="_blank" href="https://docs.microsoft.com/en-us/windows/security/threat-protection/windows-sandbox/windows-sandbox-configure-using-wsb-file#networking">Windows Sandbox configuration file</a>). </p>
<p>In this article, I am using Windows 11 Pro. Windows sandbox is also available to Windows 10 as the documentation says, and the processes are almost the same.</p>
<h2 id="heading-virtualization-with-windows-sandbox">Virtualization with Windows Sandbox</h2>
<p>This is an important part of the sandbox. As it runs on an elevated space, it must need the virtualization feature. You have to make sure that you already have enabled virtualization. </p>
<p>If you're wondering how to know whether you've enabled virtualization or not, then don't worry – I am going to show that to you!</p>
<p>Open task manager. You can right click on the Windows logo and click Task Manager, or you can use the shortcut <strong><code>Ctrl</code>  + <code>Shift</code> + <code>Esc</code></strong> for that.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/04/Screenshot-2022-04-09-181256.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>After opening the task manager, go to the <strong>Performance</strong> tab. Then click <strong>CPU</strong> and check the <strong>virtualization</strong> status like below.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/04/Screenshot-2022-04-09-181405.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>If the virtualization status says that it has already been enabled like it does on mine, then you are ready to proceed to the next steps. </p>
<p>If it says that it has been disabled, then you need to enable it from the BIOS. I'll show you how to enable virtualization below.</p>
<h2 id="heading-how-to-enable-virtualization-on-your-computer">How to enable virtualization on your computer</h2>
<p>First, go to BIOS. Depending on the manufacturer of your BIOS, it can be one of these keys to enter into BIOS during booting: Del, Esc, F1, F2, or F4. </p>
<p>When your screen goes black during the reboot process, you have to tap the BIOS key (mentioned above) quickly until the BIOS menu appears. If the key you are using does not work for you, then try rebooting your computer and do the exact process by using the other keys from the keys mentioned above until you get the key working for you.</p>
<p>After entering into BIOS, you have to find the section for your CPU configuration. You may find it under the CPU, Processor, Northbridge or Chipset tab. You may find the configuration section as Advanced or Advanced mode section in your case.</p>
<p>After getting into the CPU configuration section, you have to find the option where it allows you to enable the hardware virtualization. Depending upon your system, you may find names like Hyper-V, Vanderpool, SVM (usually motherboards of Gigabyte use this), AMD-V, Intel Virtualization Technology or simply VT-X.</p>
<p>Enable that option that appears in your case. If you see AMD IOMMU or Intel VT-d, enable them as well. </p>
<p>Then you have to save the changes. You can use the shortcut keys for that as well which should be displayed on your BIOS. Most of the manufacturers use F10 for saving the BIOS configuration. </p>
<p>Then you have to exit the BIOS. Your computer will restart once again. Then if you check the virtualization status from your task manager, you will see that it has been enabled!</p>
<p>Now, I can safely assume that the virtualization has been enabled on your computer.</p>
<h2 id="heading-how-to-enable-windows-sandbox">How to Enable Windows Sandbox</h2>
<p>Click the start button or search button and search for Windows features.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/04/Screenshot--1-.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Click <strong>Turn Windows features on or off</strong>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/04/Screenshot--2-.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>It will open the <strong>Windows Features</strong> window like the above picture.</p>
<p>Scroll down until you find <strong>Windows Sandbox</strong>:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/04/Screenshot--3-.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Make sure that you have checked the box like below:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/04/Screenshot--4-.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Then click <strong>OK</strong>.</p>
<p>It will start searching for the required files.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/04/Screenshot--5-.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Then it will apply the changes all by itself.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/04/Screenshot--6-.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>After completing the requested changes, it will ask you to restart your system. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/04/Screenshot--7-.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Click <strong>Restart now</strong>.</p>
<p>After rebooting your computer, your computer is completely ready to use the Windows sandbox.</p>
<h2 id="heading-how-to-test-windows-sandbox">How to Test Windows Sandbox</h2>
<p>Click the start menu or search bar and search for <strong>Windows Sandbox</strong>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/04/Screenshot--9-.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Windows Sandbox will be opened after that. Do not fear if you get a dark screen like below as it is normal when you first start the sandbox.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/04/Screenshot--10-.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>After a while, you will see that a new instance of your host machine has appeared right before your eyes.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/04/Screenshot--11-.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>You can maximize the sandbox window if you want.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/04/Screenshot--12-.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Now you can experiment in your sandbox. It will feel like you are using your main host machine, but you're not. You are using a temporary virtual machine with elevated privileges in an isolated environment – and whatever you do in this sandbox, your host machine will remain intact!</p>
<p>How cool is that, right! 😍</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/04/Screenshot--13-.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/04/Screenshot--14-.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>If you want to add data/software inside your sandbox, then you have to copy-paste them as you normally do on your computer. Simply copy the file/software that you want to use inside the sandbox, and in the sandbox window, simply paste them in.</p>
<h2 id="heading-how-to-close-the-sandbox">How to Close the Sandbox</h2>
<p>Be careful here! Whatever you are doing and keeping in your sandbox is happening in a temporary instance. Remember that it's not getting saved anywhere else in your host machine for later use. </p>
<p>Once you close the sandbox, all of the data/apps you are keeping in that sandbox will get deleted instantly.</p>
<p>Before closing the sandbox, you have to make sure that you have not kept anything important in the sandbox that you might need afterward, even after closing the sandbox.</p>
<p>When you want to close the sandbox, simply close the sandbox window. A prompt will appear telling you that once you close the window, all of the files/applications you have in the sandbox will be gone forever.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/04/Screenshot--15-.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>If everything is okay, then simply click OK. It will close the sandbox. </p>
<p>If you need to open the sandbox again, simply open it like earlier and do your tasks. All of the processes are exactly the same.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Thanks for reading the entire article. If it helps you then you can also check out other articles of mine at <a target="_blank" href="https://www.freecodecamp.org/news/author/fahimbinamin/">freeCodeCamp</a>.</p>
<p>If you want to get in touch with me, then you can do so using <a target="_blank" href="https://twitter.com/Fahim_FBA">Twitter</a>, <a target="_blank" href="https://www.linkedin.com/in/fahimfba/">LinkedIn</a>, and <a target="_blank" href="https://github.com/FahimFBA">GitHub</a>. </p>
<p>You can also <a target="_blank" href="https://www.youtube.com/@FahimAmin?sub_confirmation=1">SUBSCRIBE to my YouTube channel</a> (Code With FahimFBA) if you want to learn various kinds of programming languages with a lot of practical examples regularly.</p>
<p>If you want to check out my highlights, then you can do so at my <a target="_blank" href="https://www.polywork.com/fahimbinamin">Polywork timeline</a>.</p>
<p>You can also <a target="_blank" href="https://fahimbinamin.com/">visit my website</a> to learn more about me and what I'm working on.</p>
<p>Thanks a bunch!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Where are Docker Images Stored? Docker Container Paths Explained ]]>
                </title>
                <description>
                    <![CDATA[ By Sebastian Sigl Docker has been widely adopted and is used to run and scale applications in production. Additionally, it can be used to start applications quickly by executing a single Docker command.  Companies also are investing more and more eff... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/where-are-docker-images-stored-docker-container-paths-explained/</link>
                <guid isPermaLink="false">66d4610a3bc3ab877dae2234</guid>
                
                    <category>
                        <![CDATA[ containerization ]]>
                    </category>
                
                    <category>
                        <![CDATA[ containers ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Docker ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Kubernetes ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtualization ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Thu, 06 Feb 2020 19:00:00 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/02/example-of-examples-word-embeddings_grey.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Sebastian Sigl</p>
<p>Docker has been widely adopted and is used to run and scale applications in production. Additionally, it can be used to start applications quickly by executing a single Docker command. </p>
<p>Companies also are investing more and more effort into improving development in local and remote Docker containers, which comes with a lot of advantages as well.</p>
<p>You can get the basic information about your Docker configuration by executing:</p>
<pre><code class="lang-shell">$ docker info

...
 Storage Driver: overlay2
 Docker Root Dir: /var/lib/docker
...
</code></pre>
<p>The output contains information about your storage driver and your docker root directory.</p>
<h2 id="heading-the-storage-location-of-docker-images-and-containers">The storage location of Docker images and containers</h2>
<p>A Docker container consists of network settings, volumes, and images. The location of Docker files depends on your operating system. Here is an overview for the most used operating systems:  </p>
<ul>
<li>Ubuntu: <code>/var/lib/docker/</code></li>
<li>Fedora: <code>/var/lib/docker/</code></li>
<li>Debian: <code>/var/lib/docker/</code></li>
<li>Windows: <code>C:\ProgramData\DockerDesktop</code></li>
<li>MacOS: <code>~/Library/Containers/com.docker.docker/Data/vms/0/</code></li>
</ul>
<p>In macOS and Windows, Docker runs Linux containers in a virtual environment. Therefore, there are some additional things to know.</p>
<h3 id="heading-docker-for-mac">Docker for Mac</h3>
<p>Docker is not natively compatible with macOS, so <a target="_blank" href="https://github.com/moby/hyperkit">Hyperkit</a> is used to run a virtual image. Its virtual image data is located in:  </p>
<p><code>~/Library/Containers/com.docker.docker/Data/vms/0</code></p>
<p>Within the virtual image, the path is the default Docker path <code>/var/lib/docker</code>.</p>
<p>You can investigate your Docker root directory by creating a shell in the virtual environment:</p>
<pre><code class="lang-shell">$ screen ~/Library/Containers/com.docker.docker/Data/vms/0/tty
</code></pre>
<p>You can kill this session by pressing <strong>Ctrl+a</strong>, followed by pressing <strong>k</strong> and <strong>y</strong>.</p>
<h3 id="heading-docker-for-windows">Docker for Windows</h3>
<p>On Windows, Docker is a bit fractioned. There are native Windows containers that work similarly to Linux containers. Linux containers are run in a minimal Hyper-V based virtual environment.</p>
<p>The configuration and the virtual image to execute linux images are saved in the default Docker root folder.</p>
<p><code>C:\ProgramData\DockerDesktop</code></p>
<p>If you inspect regular images then you will get linux paths like:</p>
<pre><code class="lang-shell">$ docker inspect nginx

...
"UpperDir": "/var/lib/docker/overlay2/585...9eb/diff"
...
</code></pre>
<p>You can connect to the virtual image by:</p>
<pre><code class="lang-shell">docker run -it --privileged --pid=host debian nsenter -t 1 -m -u -i sh
</code></pre>
<p>There, you can go to the referenced location:</p>
<pre><code class="lang-shell">$ cd /var/lib/docker/overlay2/585...9eb/
$ ls -lah

drwx------    4 root     root        4.0K Feb  6 06:56 .
drwx------   13 root     root        4.0K Feb  6 09:17 ..
drwxr-xr-x    3 root     root        4.0K Feb  6 06:56 diff
-rw-r--r--    1 root     root          26 Feb  6 06:56 link
-rw-r--r--    1 root     root          57 Feb  6 06:56 lower
drwx------    2 root     root        4.0K Feb  6 06:56 work
</code></pre>
<h2 id="heading-the-internal-structure-of-the-docker-root-folder">The internal structure of the Docker root folder</h2>
<p>Inside <code>/var/lib/docker</code>, different information is stored. For example, data for containers, volumes, builds, networks, and clusters.</p>
<pre><code class="lang-shell">$ ls -la /var/lib/docker

total 152
drwx--x--x   15 root     root          4096 Feb  1 13:09 .
drwxr-xr-x   13 root     root          4096 Aug  1  2019 ..
drwx------    2 root     root          4096 May 20  2019 builder
drwx------    4 root     root          4096 May 20  2019 buildkit
drwx------    3 root     root          4096 May 20  2019 containerd
drwx------    2 root     root         12288 Feb  3 19:35 containers
drwx------    3 root     root          4096 May 20  2019 image
drwxr-x---    3 root     root          4096 May 20  2019 network
drwx------    6 root     root         77824 Feb  3 19:37 overlay2
drwx------    4 root     root          4096 May 20  2019 plugins
drwx------    2 root     root          4096 Feb  1 13:09 runtimes
drwx------    2 root     root          4096 May 20  2019 swarm
drwx------    2 root     root          4096 Feb  3 19:37 tmp
drwx------    2 root     root          4096 May 20  2019 trust
drwx------   15 root     root         12288 Feb  3 19:35 volumes
</code></pre>
<h3 id="heading-docker-images">Docker images</h3>
<p>The heaviest contents are usually images. If you use the default storage driver overlay2, then your Docker images are stored in <code>/var/lib/docker/overlay2</code>. There, you can find different files that represent read-only layers of a Docker image and a layer on top of it that contains your changes.</p>
<p>Let’s explore the content by using an example:</p>
<pre><code class="lang-shell">$ docker image pull nginx
$ docker image inspect nginx

[
    {
        "Id": "sha256:207...6e1",
        "RepoTags": [
            "nginx:latest"
        ],
        "RepoDigests": [
            "nginx@sha256:ad5...c6f"
        ],
        "Parent": "",
 ...
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 126698063,
        "VirtualSize": 126698063,
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/585...9eb/diff:
                             /var/lib/docker/overlay2/585...9eb/diff",
                "MergedDir": "/var/lib/docker/overlay2/585...9eb/merged",
                "UpperDir": "/var/lib/docker/overlay2/585...9eb/diff",
                "WorkDir": "/var/lib/docker/overlay2/585...9eb/work"
            },
...
</code></pre>
<p>The <strong>LowerDir</strong> contains the read-only layers of an image. The read-write layer that represents changes are part of the <strong>UpperDir</strong>. In my case, the NGINX <strong>UpperDir</strong> folder contains the log files:</p>
<pre><code class="lang-shell">$ ls -la /var/lib/docker/overlay2/585...9eb/diff

total 8
drwxr-xr-x    2 root     root    4096 Feb  2 08:06 .
drwxr-xr-x    3 root     root    4096 Feb  2 08:06 ..
lrwxrwxrwx    1 root     root      11 Feb  2 08:06 access.log -&gt; /dev/stdout
lrwxrwxrwx    1 root     root      11 Feb  2 08:06 error.log -&gt; /dev/stderr
</code></pre>
<p>The <strong>MergedDir</strong> represents the result of the <strong>UpperDir</strong> and <strong>LowerDir</strong> that is used by Docker to run the container. The <strong>WorkDir</strong> is an internal directory for overlay2 and should be empty.</p>
<h3 id="heading-docker-volumes">Docker Volumes</h3>
<p>It is possible to add a persistent store to containers to keep data longer than the container exists or to share the volume with the host or with other containers. A container can be started with a volume by using the <strong>-v</strong> option:</p>
<pre><code class="lang-shell">$ docker run --name nginx_container -v /var/log nginx
</code></pre>
<p>We can get information about the connected volume location by:</p>
<pre><code class="lang-shell">$ docker inspect nginx_container

...
"Mounts": [
            {
                "Type": "volume",
                "Name": "1e4...d9c",
                "Source": "/var/lib/docker/volumes/1e4...d9c/_data",
                "Destination": "/var/log",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            }
        ],
...
</code></pre>
<p>The referenced directory contains files from the location <code>/var/log</code> of the NGINX container.</p>
<pre><code class="lang-shell">$ ls -lah /var/lib/docker/volumes/1e4...d9c/_data

total 88
drwxr-xr-x    4 root     root        4.0K Feb  3 21:02 .
drwxr-xr-x    3 root     root        4.0K Feb  3 21:02 ..
drwxr-xr-x    2 root     root        4.0K Feb  3 21:02 apt
-rw-rw----    1 root     43             0 Jan 30 00:00 btmp
-rw-r--r--    1 root     root       34.7K Feb  2 08:06 dpkg.log
-rw-r--r--    1 root     root        3.2K Feb  2 08:06 faillog
-rw-rw-r--    1 root     43         29.1K Feb  2 08:06 lastlog
drwxr-xr-x    2 root     root        4.0K Feb  3 21:02 nginx
-rw-rw-r--    1 root     43             0 Jan 30 00:00 w
</code></pre>
<h2 id="heading-clean-up-space-used-by-docker">Clean up space used by Docker</h2>
<p>It is recommended to use the Docker command to clean up unused containers. Container, networks, images, and the build cache can be cleaned up by executing:</p>
<pre><code class="lang-shell">$ docker system prune -a
</code></pre>
<p>Additionally, you can also remove unused volumes by executing:</p>
<pre><code class="lang-shell">$ docker volumes prune
</code></pre>
<h2 id="heading-summary"><strong>Summary</strong></h2>
<p>Docker is an important part of many people’s environments and tooling. Sometimes, Docker feels a bit like magic by solving issues in a very smart way without telling the user how things are done behind the scenes. Still, Docker is a regular tool that stores its heavy parts in locations that can be opened and changed. </p>
<p>Sometimes, storage can fill up quickly. Therefore, it’s useful to inspect its root folder, but it is not recommended to delete or change any files manually. Instead, the prune commands can be used to free up disk space.</p>
<p>I hope you enjoyed the article. If you like it and feel the need for a round of applause, <a target="_blank" href="https://twitter.com/sesigl">follow me on Twitter</a>. I work at eBay Kleinanzeigen, one of the biggest classified companies globally. By the way, <a target="_blank" href="https://jobs.ebayclassifiedsgroup.com/ebay-kleinanzeigen">we are hiring</a>!</p>
<p>Happy Docker exploring :)</p>
<h2 id="heading-references">References</h2>
<ul>
<li>Docker storagediver documentation<br><a target="_blank" href="https://docs.docker.com/storage/storagedriver/">https://docs.docker.com/storage/storagedriver/</a></li>
<li>Documentation Overlay filesystem<br><a target="_blank" href="https://www.kernel.org/doc/Documentation/filesystems/overlayfs.txt">https://www.kernel.org/doc/Documentation/filesystems/overlayfs.txt</a></li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Use Linux Containers With LXC and LXD ]]>
                </title>
                <description>
                    <![CDATA[ In the good old days, installing an operating system meant pulling together all the hardware components, firing your new computer up with an installation disk in a peripheral drive, and setting the installation process loose do its thing. The total e... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/linux-containers-lxc-lxd/</link>
                <guid isPermaLink="false">66b9960565fc624db0255dd1</guid>
                
                    <category>
                        <![CDATA[ containers ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Linux ]]>
                    </category>
                
                    <category>
                        <![CDATA[ lxd ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtualization ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ David Clinton ]]>
                </dc:creator>
                <pubDate>Thu, 16 Jan 2020 14:00:00 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/01/containers.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>In the good old days, installing an operating system meant pulling together all the hardware components, firing your new computer up with an installation disk in a peripheral drive, and setting the installation process loose do its thing. The total elapsed time could run anywhere between hours and weeks. </p>
<p>These days I can say to myself "I wouldn't mind testing that on a server running a particular version of CentOS" and - depending on a number of variables and assuming the original image has already been downloaded - I can have a fully-functioning virtual system ready within 30 seconds. Your exact results may vary, but not by that much. </p>
<p>You can see how all this works in my new <a target="_blank" href="https://pluralsight.pxf.io/RqrJb">Pluralsight "Linux System Optimization" course</a> - on which this article is based.</p>
<p>What's been driving all this change? Virtualization. And, in particular, container virtualization. </p>
<p>A virtualized OS is a file system containing all the software libraries, binaries, and configuration files you would need to launch a traditional machine. It's just that this particular file system isn't stored in the root or boot partition that your computer would read as it powers on, but on some other part of your storage volume. </p>
<p>And "powering up" your virtual computer happens when some software cleverly fools the files into thinking they're running all by themselves on their own hardware, when they're really sharing space and resources with the host operating system and, perhaps, some other virtual computers.</p>
<p>Broadly speaking, there are two kinds of software systems used for server virtualization administration: hypervisor and container. </p>
<p>Hypervisors provide a layer of abstraction that permits guest VMs to create an isolated environment with access to the system hardware that emulates a bare metal server. This means that hypervisor VMs can be built from any operating system compatible with your underlying hardware. But it also means that they'll use up more space and more memory and compute resources.</p>
<h2 id="heading-container-virtualization">Container Virtualization</h2>
<p>Containers, on the other hand, share the host computer's OS kernel and exist within carefully secured and isolated spaces managed by system tools like cgroups. Because they share the kernel, the memory and system resources consumed by containers can be truly minimal, with absolutely nothing wasted. And, as you'll see, the speeds you'll get running container applications will be breathtaking.</p>
<p>A lot of container-related attention over the past few years has been focused on Docker and, more recently, Google's container orchestration tool, Kubernetes. In fact, Kubernetes is well suited for enterprise-scale microservices architectures. </p>
<p>But there's an older and, arguably, more mature implementation of the container model that hasn't gone anywhere. The <a target="_blank" href="https://linuxcontainers.org/">Linux Container Project, LXC,</a> and its more recent toolset, LXD, have strengths that many would argue make it a better candidate for some use cases than Kubernetes. In particular, LXC excels at building light and fast sandboxed environments for testing and application development.</p>
<p>In this article, I'm going to show you how to install LXD, how to prepare and launch a simple container running the ultra-small Alpine Linux, and then how to open a shell session within your new container. I'll also explain how to find and launch multiple versions of other distributions.</p>
<p>One thing I can tell you right away is that whenever I teach LXC, students respond with amazement at how powerful and efficient using containers can be. </p>
<p>When we're done with all this, you'll be able to fire up machines to hands-on test out whatever it is you're learning or working within seconds. When an experiment goes bad, you can instantly shutdown and remove a container and build another one to replace it. There's simply no longer any excuse not to learn.</p>
<h2 id="heading-building-lxd-containers">Building LXD Containers</h2>
<p>We're going to get LXC running working on a fresh install of an Ubuntu 18.04 machine. In this demo, we'll install and initialize an LXD environment and then use the LXD version of the LXC command line interface to download and launch an Alpine Linux container. We'll confirm everything worked and then take a bit of a look around to see how the environment is populated.</p>
<p>I'm going to use the snap package manager to install LXD because that's now the official recommendation. And not just for LXD, mind you: all kinds of applications are drifting to alternate managers like snap or AppImmage and Flatpak. I still love my Debian aptitude, but you can't fight the whole world.</p>
<pre><code>$ sudo snap install lxd
</code></pre><p>LXD - which, again, is an updated toolset designed to manage the LXC API - comes in a package that includes all the regular LXC dependencies. One install command and we're done. </p>
<p>It's important to initialize the LXC environment using the lxd init command. You could set things up yourself manually, but you're more likely to get it all right this way. The init process will ask you a bunch of questions and, for now at least, the default answers will all work.</p>
<pre><code>$ sudo lxd init
</code></pre><p>Once that's done, we're ready to build your first container. Whichever Linux distribution and version we want, we'll need to find and download the image. The LXC project maintains a repository of quite a range of images at <a target="_blank" href="https://us.images.linuxcontainers.org/">images.linuxcontainers.org</a>. You can see that there are usually multiple versions of each distro, permitting you to build containers that'll work with just about any software you can throw at it.</p>
<p>I'm going to use the latest version of Alpine Linux because it's really small. Feel free to use any image you like - including the big boys like Ubuntu and CentoOS. Alpine, of course, will download very quickly. </p>
<p>But before we do that, I should tell you how to figure out the command line syntax necessary to get your image. </p>
<p>As you can see in this screen shot from the LXD website, you can get three pieces of information you'll need from the page itself: the name of the distro - Alpine, in this case - the release number - 3.10 - and the architecture. We're after amd64.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/01/lxd-images-1.png" alt="Image" width="600" height="400" loading="lazy">
<em>From the images.linuxcontainers.org page</em></p>
<p>We're now ready to trigger the download by running the <code>launch</code> command:</p>
<pre><code>$ sudo lxc launch images:alpine/<span class="hljs-number">3.10</span>/amd64 demo
</code></pre><p>Notice how the syntax is "lxc" even though this is technically an LXD interface. "images" tells LXC that our image lives in the public repo we saw earlier. Our three bits of data - the distro name, release number, and architecture, are entered separated by forward slashes. I'll use "demo" as the name of my container. That should be all we need. </p>
<p>You can see how small Alpine is by how quickly it downloads. My internet connection isn't that fast and I haven't played any games with the recording. To confirm that it worked, I'll run "lxc ls" to list all the containers currently installed. There's just the one. And its current status is "running".</p>
<pre><code>sudo lxc ls
+------+---------+----------------------+------------+-----------+
| NAME |  STATE  |         IPV4         |    TYPE    | SNAPSHOTS |
+------+---------+----------------------+------------+-----------+
| demo | RUNNING | <span class="hljs-number">10.125</span><span class="hljs-number">.45</span><span class="hljs-number">.119</span> (eth0) | PERSISTENT | <span class="hljs-number">0</span>         |
+------+---------+----------------------+------------+-----------+
</code></pre><p>You can open a non-login root session in a container using the "lxc exec" command. Just specify the container name and then tell LXC that you want to run a shell using the sh interpreter (you might prefer <code>/bin/bash</code> if you're working with an Ubuntu or CentOS container - your call either way). As you'll be able to see for yourself if you're following along at home, we've got a normal Linux command prompt and anything Linux-y is now possible.</p>
<pre><code>$ sudo lxc exec demo sh
~ #
</code></pre><p>You could also run a single command without opening a full shell by typing the command instead of this <code>sh</code>.</p>
<pre><code>$ sudo lxc exec demo ls /
bin    etc    lib    mnt    proc   run    srv    tmp    <span class="hljs-keyword">var</span>
dev    home   media  opt    root   sbin   sys    usr
</code></pre><p>You can bail out of the shell any time you like using <code>exit</code> and return to your host. Here, besides listing running containers, I can also list any storage pools. The default pool that was created during initialization is there, and we can see where the disk image is stored. /var/lib/lxd is, by default, where all LXC resources are kept.</p>
<pre><code>$ sudo lxc storage ls
+---------+-------------+--------+--------------------------------+---------+
|  NAME   | DESCRIPTION | DRIVER |             SOURCE             | USED BY |
+---------+-------------+--------+--------------------------------+---------+
| <span class="hljs-keyword">default</span> |             | btrfs  | <span class="hljs-regexp">/var/</span>lib/lxd/disks/<span class="hljs-keyword">default</span>.img | <span class="hljs-number">3</span>       |
+---------+-------------+--------+--------------------------------+---------+
</code></pre><p>I can similarly list all my networks. There happen to be a few network bridges on this system (I've been playing around a bit, as you can see). There's also the physical enp0s3 bridge used by the host Ubuntu server. Although between you and me, that one's not physical either, as this is actually a VM running in Oracle's Virtual Box.</p>
<pre><code>$ lxc network ls
+---------+----------+---------+-------------+---------+
|  NAME   |   TYPE   | MANAGED | DESCRIPTION | USED BY |
+---------+----------+---------+-------------+---------+
| enp0s3  | physical | NO      |             | <span class="hljs-number">1</span>       |
+---------+----------+---------+-------------+---------+
| lxdbr0  | bridge   | YES     |             | <span class="hljs-number">1</span>       |
+---------+----------+---------+-------------+---------+
| mynet   | bridge   | YES     |             | <span class="hljs-number">0</span>       |
+---------+----------+---------+-------------+---------+
| testbr0 | bridge   | YES     |             | <span class="hljs-number">1</span>       |
+---------+----------+---------+-------------+---------+
</code></pre><p>If we needed to, we could easily add a new virtual interface to our container using the "lxc network attach" command. Here, I'll specify the physical network and then the name of our container.</p>
<pre><code>$ lxc network attach enp0s3 demo
</code></pre><p>With that done, you could open a new shell in the container to see what's changed. There should now be an eth1 interface listed. You may need to reboot for all the changes to take full effect. By doing that you can also marvel at just how fast this thing can reboot itself - for all intents and purposes, it'll happen faster than you can type your <code>exec</code> command to open a new shell.</p>
<p>Enjoy your new environment!</p>
<p><em>This article is based on content in my <a target="_blank" href="https://pluralsight.pxf.io/RqrJb">Pluralsight course, "Linux System Optimization."</a> There's much more administration goodness in the form of books, courses, and articles available at <a target="_blank" href="https://bootstrap-it.com">bootstrap-it.com</a>.</em></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Run Commands on Multiple Linux Hosts Using PSSH ]]>
                </title>
                <description>
                    <![CDATA[ I'm sure you've heard that all the cool kids are playing with orchestration automation these days. But do you know why? Well first, the resources consumed by modern microservices workloads are becoming much more complex and deploy to far more instanc... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/running-commands-linux-hosts-using-pssh/</link>
                <guid isPermaLink="false">66b9962a7bb37b73c3f3c4ea</guid>
                
                    <category>
                        <![CDATA[ Linux ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Orchestration ]]>
                    </category>
                
                    <category>
                        <![CDATA[ ssh ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtualization ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ David Clinton ]]>
                </dc:creator>
                <pubDate>Thu, 09 Jan 2020 14:00:00 +0000</pubDate>
                <media:content url="https://cdn-media-2.freecodecamp.org/w1280/5f9c9e08740569d1a4ca3af6.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>I'm sure you've heard that all the cool kids are playing with orchestration automation these days. But do you know why? Well first, the resources consumed by modern microservices workloads are becoming much more complex and deploy to far more instances than ever before. And second, more and more of those resources are virtual rather than physical - so many of them will only exist for minutes or even seconds.</p>
<p>All of which means that even if you wanted to go around logging into each of your many servers, it just wouldn't make sense. In most cases in fact, it wouldn't even be possible. Instead, you're going to be running a lot of clever scripts. And the tools you use to run those kinds of scripts are generally called orchestrators.</p>
<p>I'm sure you've encountered at least one or two members of the orchestration club. Besides Ansible, there's Terraform, Chef, Puppet and others. But there are also lower-level tools that work as add-ons to core Linux tools like SSH. Although, seeing how it'll run natively on Windows and, of course, macOS, I'm not sure it's quite correct to call SSH a "Linux" tool any more. </p>
<p>One of those SSH add-ons is a tool set called pssh - which stands for Parallel SSH. That's what we're going to be learning about in this article - which is excerpted from my new <a target="_blank" href="https://pluralsight.pxf.io/RqrJb">Pluralsight course, Linux System Optimization</a>.</p>
<p>For now, though, I'm going to tell you a bit about the lab I'm using so that you can more easily reproduce it and follow along at home. I've got three Ubuntu <a target="_blank" href="https://www.freecodecamp.org/news/linux-containers-lxc-lxd/">LXD containers</a> running. The base for all of our operations will be the one with an IP address of 10.0.3.140, while the two host nodes we'll be remotely provisioning will use 10.0.3.93 and 10.0.3.43.</p>
<p>Everything we'll do assumes that we've got passwordless SSH access from my base container to each of the two nodes. If you're not sure how to do that, you can view the SSH module of my <a target="_blank" href="https://pluralsight.pxf.io/9DYVe">Protocol Deep Dive: SSH and Telnet course</a> on Pluralsight. If you're in a hurry, <a target="_blank" href="https://www.redhat.com/sysadmin/passwordless-ssh">this Red Hat tutorial</a> will get you to the same place.</p>
<p>Installing pssh on Ubuntu is simple and quick: <code>sudo apt install pssh</code>. It doesn't get any harder on CentOS.</p>
<p>I created a simple host inventory file called sshhosts.txt that contains nothing more than the IP addresses of my two nodes:</p>
<pre><code>$ less sshhosts.txt
<span class="hljs-number">10.0</span><span class="hljs-number">.3</span><span class="hljs-number">.93</span>
<span class="hljs-number">10.0</span><span class="hljs-number">.3</span><span class="hljs-number">.43</span>
</code></pre><p>Now I'm going to run the pssh parallel-ssh command to execute a single command on my hosts.</p>
<pre><code>$ parallel-ssh -i -h sshhosts.txt df -ht ext4
</code></pre><p>-i tells the program to run as interactive - otherwise we wouldn't be shown any command output. -h points to the hosts file that I called sshhosts.txt. And the command itself will be the old Unix utility df. That'll return a list of drives attached to the system along with their mount points and usage information. The -h here will display disk space in human readable units and the t will restrict access to only drives formatted as ext4. </p>
<p>Why do I care about that ext4 business? Because Ubuntu uses the snap package manager and each snap creates its own virtual device. So what? Well, I don't want to have to comb through a dozen or so virtual devices reporting 0 free space just to get to the real drives reporting actual usage.</p>
<pre><code>$ parallel-ssh -i -h sshhosts.txt df -ht ext4
[<span class="hljs-number">1</span>] <span class="hljs-number">22</span>:<span class="hljs-number">02</span>:<span class="hljs-number">00</span> [SUCCESS] <span class="hljs-number">10.0</span><span class="hljs-number">.3</span><span class="hljs-number">.43</span>
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2       <span class="hljs-number">457</span>G  <span class="hljs-number">131</span>G  <span class="hljs-number">304</span>G  <span class="hljs-number">30</span>% /
[<span class="hljs-number">2</span>] <span class="hljs-number">22</span>:<span class="hljs-number">02</span>:<span class="hljs-number">00</span> [SUCCESS] <span class="hljs-number">10.0</span><span class="hljs-number">.3</span><span class="hljs-number">.93</span>
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2       <span class="hljs-number">457</span>G  <span class="hljs-number">131</span>G  <span class="hljs-number">304</span>G  <span class="hljs-number">30</span>% /
</code></pre><p>And there you go! Full disk space information about both of my nodes. I'm sure you noticed that the information is identical. That's because these are both containers running on my workstation, so as far as they know, they both have full access to my own drive.</p>
<p>For my next trick, I'll collect the /etc/group files from each of my nodes. This is the kind of operation that could be useful to quickly monitor the security status of your nodes. You could add a script that parses the incoming data and alerts you if there are any anomalies. </p>
<p>Before I begin, I'll create a directory locally called host-files. Then I'll use the <code>parallel-slurp</code> command - whose name wonderfully describes its function. Again, -h points to the hosts file. The <code>-L</code> sets the host-files directory as the target location for writing the data we're going to generate, <code>/etc/group</code> is the remote file we want to slurp up, and <code>group</code> is the name we'd like to assign the data locally.</p>
<pre><code>mkdir host-files
parallel-slurp -h sshhosts.txt -L host-files/ <span class="hljs-regexp">/etc/g</span>roup group
</code></pre><p>When it's done, your host-files directory will contain sub-directories named after the IP address of each of your nodes. As you can see, there's a file called "group" that contains the /etc/group data from each node.</p>
<pre><code>$ tree host-files/
host-files/
├── <span class="hljs-number">10.0</span><span class="hljs-number">.3</span><span class="hljs-number">.43</span>
│   └── group
└── <span class="hljs-number">10.0</span><span class="hljs-number">.3</span><span class="hljs-number">.93</span>
    └── group
</code></pre><p>Does pssh come with any other treats? Yup. And running <code>apropos</code> gives you the whole list.</p>
<pre><code>$ apropos parallel
parallel-nuke (<span class="hljs-number">1</span>)    - parallel process kill program
parallel-rsync (<span class="hljs-number">1</span>)   - parallel process kill program
parallel-scp (<span class="hljs-number">1</span>)     - parallel process kill program
parallel-slurp (<span class="hljs-number">1</span>)   - parallel process kill program
parallel-ssh (<span class="hljs-number">1</span>)     - parallel ssh program
</code></pre><p><em>This article is based on content in my <a target="_blank" href="https://pluralsight.pxf.io/RqrJb">Pluralsight course, "Linux System Optimization."</a> There's much more administration goodness in the form of books, courses, and articles available at <a target="_blank" href="https://bootstrap-it.com">bootstrap-it.com</a>.</em></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ A Simple Introduction to Kubernetes Container Orchestration ]]>
                </title>
                <description>
                    <![CDATA[ In the beginning there was the FreeBSD - and later Linux - chroot jail. Chroot was a way to bring an unmounted file system to life so you could execute commands as though it was actually running on its own host. Then came the Linux Containers project... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/a-simple-introduction-to-kubernetes-container-orchestration/</link>
                <guid isPermaLink="false">66b9959417d9592471979c21</guid>
                
                    <category>
                        <![CDATA[ Kubernetes ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtualization ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ David Clinton ]]>
                </dc:creator>
                <pubDate>Wed, 30 Oct 2019 13:00:00 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2019/10/adult-audience-band-2102568.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>In the beginning there was the FreeBSD - and later Linux - chroot jail. Chroot was a way to bring an unmounted file system to life so you could execute commands as though it was actually running on its own host. Then came the Linux Containers project (LXC and LXD) that added network and storage configurations to run jails (now more commonly called containers) within appropriately isolated and optimized environments.</p>
<p>And then there was Docker. Docker containers streamlined container operations so that software resources used by multiple containers could be efficiently shared. They also added online public repositories populated by vast collections of software tools. But the real value of Docker was in how easy it made deploying reliably predictable application environments.</p>
<h3 id="heading-what-kubernetes-brings-to-the-table">What Kubernetes Brings to the Table</h3>
<p>Then, out of the mists of time appeared Kubernetes. While originally developed within Google, Kubernetes has since been released as open source software under the control of the Cloud Native Computing Foundation. </p>
<p>At its heart, Kubernetes manages containers just the way Docker does. But Kubernetes adds a vast ecosystem of scaling, load balancing, network proxying, and multi-node administration tools to the mix. Docker’s own Swarm comes with a comparable suite of tools, but Kubernetes has, so far at least, proven far more popular.</p>
<p>Kubernetes is much more of a native enterprise-scale tool than Docker Swarm. It's not that Docker Swarm can't be used in the enterprise - it certainly can - it's that Kubernetes isn't necessarily such a great fit for a quick and dirty local development environment. The main reason is that, at this point at any rate, you need an existing cluster before you can get anything to happen, and creating a local cluster requires a running hypervisor of one flavor or another. So having a public cloud like AWS where you can freely provision all the bits and pieces that go into a cluster without having to worry about infrastructure, matters more for Kubernetes than it does for Docker in general.</p>
<p>Kubernetes' larger resource footprint and steeper learning curve can be offset by some impressive integration: working with persistent storage volumes is straightforward. And robust deployment monitoring solutions are easily available.</p>
<h3 id="heading-a-quick-look-at-the-kubernetes-cluster">A Quick Look at the Kubernetes Cluster</h3>
<p>Here - based on content from <a target="_blank" href="https://pluralsight.pxf.io/nZgKx">my Pluralsight course, “Using Docker on AWS”</a> - is how Kubernetes works. A cluster is made up of the networking, storage, and compute resources that your workloads will use. The cluster's physical or virtual computers - called nodes - serve as either primaries or replicas. A primary runs the services that manage all cluster operations. The primary itself is managed through the kube-apiserver service which responds to instructions you send to it using the kubectl client software. The primary also hosts:</p>
<blockquote>
<p>• A database of cluster configuration known as etcd<br>• kube-controller-manager, that measures the current state of a cluster<br>against its desired state<br>• kube-scheduler, which balances configuration specifications against avail-<br>able resources<br>• The cloud-controller-manager that provides critical integration with public<br>cloud providers like AWS</p>
</blockquote>
<p>Nodes are controlled by software agents called kubelets and maintain reliable and secure network connectivity through the kube-proxy service. Important stuff - your actual application workload - happens on the nodes within pods, which are organizing structures within which the application containers themselves run. Multiple containers can run on a pod, all sharing a single IP address and compute resources - providing a single instance of your application.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/cluster.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>The components of a typical Kubernetes environment</em></p>
<p>The good news is that the kubectl software is smart enough to simply read your YAML configuration document and use it to bring all the details to life without your help. If you want to become a successful Kubernetes admin you really should understand all these details. But you can be forgiven for being a bit relaxed about it all in the meantime: most of the action takes place invisibly, hidden by the relatively simple command set we'll soon see.</p>
<h3 id="heading-a-quick-kubernetes-installation">A Quick Kubernetes Installation</h3>
<p>Just so you can't say I didn't show you anything practical here, let's install the lightweight Kubernetes version, MicroK8s, on a Linux machine. All you'll need for this in-and-out exercise is a working copy of the Snaps package manager. This single command will install all the core services, libraries, and binaries necessary for small, proof-of-concept demos.</p>
<pre><code>snap install microk8s --classic
</code></pre><p>Just to prove that the installation succeeded, ask the service to list all the nodes<br>that are currently running. Of course, there won’t be any of those yet.</p>
<pre><code>$ sudo microk8s.kubectl get nodes
No resources found.
</code></pre><p>There will, however, be a single service with a private IP address associated with<br>it:</p>
<pre><code>$ sudo microk8s.kubectl get services
NAME         TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)   AGE
kubernetes   ClusterIP   <span class="hljs-number">10.152</span><span class="hljs-number">.183</span><span class="hljs-number">.1</span>   &lt;none&gt;        <span class="hljs-number">443</span>/TCP   <span class="hljs-number">80</span>s
</code></pre><p>Finally, you can enable the browser-based Kubernetes administration dashboard using this microk8s.enable command. The output you'll get will include extra instructions for displaying and using the authentication token you'll need to connect.</p>
<pre><code>$ sudo microk8s.enable dns dashboard
Enabling DNS
Applying manifest
serviceaccount/coredns created
configmap/coredns created
[...]
If RBAC is not enabled access the dashboard using the <span class="hljs-keyword">default</span> token retrieved <span class="hljs-keyword">with</span>:

token=$(microk8s.kubectl -n kube-system get secret | grep <span class="hljs-keyword">default</span>-token | cut -d <span class="hljs-string">" "</span> -f1)
microk8s.kubectl -n kube-system describe secret $token
</code></pre><p>In an RBAC enabled setup (microk8s.enable RBAC) you need to create a user with restricted permissions as shown in <a target="_blank" href="https://github.com/kubernetes/dashboard/wiki/Creating-sample-user">https://github.com/kubernetes/dashboard/wiki/Creating-sample-user</a></p>
<p><em>This article is based on content in <a target="_blank" href="https://pluralsight.pxf.io/nZgKx">my Pluralsight course, "Using Docker on AWS."</a> There's much more administration goodness in the form of books, courses, and articles available at <a target="_blank" href="https://bootstrap-it.com">bootstrap-it.com</a>.</em></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Chroot: the magical healing powers of the original Linux virtualization tool ]]>
                </title>
                <description>
                    <![CDATA[ You know that the passwords chosen by the people you support are probably not strong enough to protect your infrastructure against a serious attack. And even the few exceptions to the rule are probably being reused on multiple servers and accounts. Y... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/chroot-magical-linux-virtualization-tool/</link>
                <guid isPermaLink="false">66b995c5c39234149cf010f5</guid>
                
                    <category>
                        <![CDATA[ Linux ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtualization ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ David Clinton ]]>
                </dc:creator>
                <pubDate>Mon, 26 Aug 2019 13:30:00 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2019/08/permission.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>You know that the passwords chosen by the people you support are probably not strong enough to protect your infrastructure against a serious attack. And even the few exceptions to the rule are probably being reused on multiple servers and accounts. You beg and nag, but it’s a losing battle.</p>
<p>But all is not entirely lost. The problem of keeping track of<br>sufficiently complex passwords can be largely solved by using a good<br>password vault like KeePass2 or LastPass. And the problem of overusing<br>passwords can be at least blunted by implementing a single sign-on<br>solution like Kerberos. Ok. Not <em>like</em> Kerberos, but <em>Kerberos</em>.</p>
<p>Still, dumb mistakes are always going to happen.</p>
<p>So what’s bound to happen to the one or two users who care enough to dream up good, strong passwords for each server they access? Every now and then they’ll forget a password, of course. That won’t be a problem if there’s another admin with sudo power who can log into the server and run passwd to create a new password for the user.</p>
<pre><code>sudo  passwd username
[sudo] password <span class="hljs-keyword">for</span> yourname:
Enter <span class="hljs-keyword">new</span> UNIX password:
Retype <span class="hljs-keyword">new</span> UNIX password:
passwd: password updated successfully
</code></pre><p>But if your unlucky and forgetful user was the only admin with an account on that machine, you’ve got trouble. Except that you don’t. <em>chroot</em> — the grandfather of all Linux virtualization — is going to save your day.</p>
<p>Here, as I wrote in <a target="_blank" href="https://www.manning.com/livevideo/linux-in-motion?a_aid=bootstrap-it&amp;a_bid=0c56986f&amp;chan=motion1">chapters 6 and 9 in my Linux in Action book</a>, is one way that it might work. Use a live-boot drive to power up the server that’s got you locked out.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/08/image-155.png" alt="Image" width="600" height="400" loading="lazy">
<em>Steps for creating a Linux live boot USB</em></p>
<p>Then open a terminal and run lsblk to determine the designation of your root partition on the server’s hard disk, and mount the root partition to a temporary directory.</p>
<pre><code>mkdir /run/mountdir/
mount /dev/sdb1 /run/mountdir/
</code></pre><p>Then you whisper the magic words and you’re in:</p>
<pre><code>chroot /run/mountdir/
root@ubuntu:/#
</code></pre><p>That’s all it takes. At this point, you’re free to run commands as though you were working on a running version of the physical hard drive. Use passwd to give your admin a new password to replace the lost one and, after typing exit to shut down your chroot session, reboot the machine (without the live-boot USB). Everything should now be fine.</p>
<blockquote>
<p><em>To encrypt or not to encrypt</em></p>
<p><em>Encrypting the data on your storage drives using tools like ecryptfs or dm-crypt makes it a great deal less likely that your data will be compromised. But on the other hand, many rescue and recovery operations like the above chroot trick simply won’t work on an encrypted volume.</em></p>
<p><em>Striking a balance between security and accessibility isn’t an exact</em><br><em>science. Many admins, for instance, will leave local servers and desktop workstations unencrypted — because they’re at least protected by locked office doors — but insist that mobile devices be encrypted.</em></p>
</blockquote>
<h2 id="heading-recovering-a-locked-vm">Recovering a locked VM</h2>
<p>You can apply the magic of chroot to clean up all kinds messes. Locked out of a local server (or LXC container)? Feel free to open a chroot shell to disable or even reconfigure your firewall.</p>
<p>Getting that done on a physical machine should be straightforward by now. But here’s how it would work on an LXC container.</p>
<p>First of all, stop the container and then run chroot against the rootfs directory<br>that’s within the directory hierarchy used by your LXC container ( var/lib/lxc/<br>your-container-name/ ). The command prompt you’ll get will allow you to execute commands as if the container was actually running. Now disable ufw or, if you prefer, run the necessary commands to fix the problem and then exit the chroot shell. When you start the container back up again, you should now have SSH access.</p>
<pre><code>lxc-stop -n your-container-name
chroot /<span class="hljs-keyword">var</span>/lib/lxc/your-container-name/rootfs/
ufw disable
exit
lxc-start -d -n your-container-name
</code></pre><p><em>This article is excerpted from my</em> <a target="_blank" href="https://www.manning.com/books/linux-in-action?a_aid=bootstrap-it&amp;a_bid=4ca15fc9"><em>Manning “Linux in Action” book</em></a><em>. There’s lots more fun</em> <a target="_blank" href="https://bootstrap-it.com/index.php/books/"><em>where this came from</em></a><em>, including a hybrid course called</em> <a target="_blank" href="https://www.manning.com/livevideo/linux-in-motion?a_aid=bootstrap-it&amp;a_bid=0c56986f&amp;chan=motion1"><em>Linux in Motion</em></a><em>that’s made up of more than two hours of video and around 40% of the text of Linux in Action. Who knows…you might also enjoy my recently published</em> <a target="_blank" href="https://www.manning.com/books/learn-amazon-web-services-in-a-month-of-lunches?a_aid=bootstrap-it&amp;a_bid=1c1b5e27"><em>Learn Amazon Web Services in a Month of Lunches</em></a><em>.</em></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Will Cisco Be the Next Roadkill for AWS? ]]>
                </title>
                <description>
                    <![CDATA[ I’m not keeping very close track, but it feels like months since Amazon Web Services (AWS) most recently turned a major tech industry upside down. But with all their resources and market power, I’m sure there’s always something interesting cooking in... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/will-cisco-be-the-next-roadkill-for-aws/</link>
                <guid isPermaLink="false">66b9967b22379234769e45f9</guid>
                
                    <category>
                        <![CDATA[ AWS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ networking ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtualization ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ David Clinton ]]>
                </dc:creator>
                <pubDate>Wed, 07 Aug 2019 13:30:00 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2019/08/cisco.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>I’m not keeping very close track, but it feels like months since Amazon Web Services (AWS) most recently turned a major tech industry upside down. But with all their resources and market power, I’m sure there’s always something interesting cooking in the kitchens of wherever Amazon’s headquarters happens to be right now.</p>
<p>So let me throw my purely speculative prediction into the silence. As I describe in my <a target="_blank" href="https://www.manning.com/books/learn-amazon-web-services-in-a-month-of-lunches?a_aid=bootstrap-it&amp;a_bid=1c1b5e27&amp;chan=medium">Learn AWS in a Month of Lunches book</a>, AWS has happily replaced your server room with EC2, your SAN and NAS with S3, your data warehousing with Redshift, and your database with RDS (and Aurora). They’ve also invented entirely new deployment models: politely informing you, for instance, that you simply have to serve your mobile apps via serverless functions (Lambda).</p>
<p>So what’s next? Well how about enterprise routing?</p>
<h2 id="heading-what-is-enterprise-routing-these-days">What is enterprise routing these days?</h2>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/08/image-18.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>For decades, large organizations have controlled their internal network traffic with switches and routers configured by proprietary operating systems. The hardware is expensive (a single appliance can easily hit $10,000) and the cost of hiring the trained admins needed to maintain them can be much higher.</p>
<p>But is all that really still necessary?</p>
<p>These days your workloads are more likely to live in the cloud than in your actual office. Even in-house Internet of Things devices can easily be controlled from the cloud using, for instance, <a target="_blank" href="https://aws.amazon.com/iot/">AWS IoT</a>. I’m guessing that most modern on-premises enterprise routing involves controlling how people connect to production resources and to each other (email, VOIP, video) — but even that is more and more likely to be outsourced to SaaS solutions.</p>
<p>I may be missing something, but I just don’t see a compelling case for hardware switches here. Software-defined networking (SDN) should easily be up to the task. Why not just cover your campus in wireless access points, authenticate users using Kerberos or Active Directory, and configure your way to permissions/connectivity perfection.</p>
<h2 id="heading-how-aws-can-rule-the-routing-world">How AWS can rule the routing world?</h2>
<p>Which brings me back to AWS. They’ve already got all the bases covered for authentication (<a target="_blank" href="https://aws.amazon.com/directoryservice/">AWS Directory Service</a>) and high-end remote connectivity (<a target="_blank" href="https://aws.amazon.com/directconnect/">AWS Direct Connect</a>). It probably wouldn’t take much for them to extend their networks to your campus. Perhaps they’d allow you to create local <a target="_blank" href="https://aws.amazon.com/vpc/">VPCs</a> — complete with configurable subnets — that you’d use to organize your local infrastructure.</p>
<p>I’m imagining a company’s admin logging into the AWS Console to onboard a couple of new hires from marketing. They’d be added to an AWS IAM “Marketing” group that’s already got access to Amazon QuickSight dashboards and streaming data from your public-facing web servers running on EC2. But the group could just as easily be configured to allow its members into a database that, for regulatory reasons, must remain local.</p>
<p>What do you think? Are the days of the proprietary system network admin numbered?</p>
<p><em>Looking for more? You might enjoy my</em> <a target="_blank" href="https://bootstrap-it.com/"><em>books and Pluralsight courses</em></a> <em>on Linux, AWS, and Docker-related topics.</em></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ AWS announced a move from Xen towards KVM. So what is KVM? ]]>
                </title>
                <description>
                    <![CDATA[ Tied up in a AWS announcement about a new EC2 high-end instance type (the C5) is a strong suggestion that Amazon’s cloud computing giant has begun to shift its hundreds of thousands of physical servers away from the open source Xen hypervisor that’s ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/aws-just-announced-a-move-from-xen-towards-kvm-so-what-is-kvm/</link>
                <guid isPermaLink="false">66b995b077e922646120d725</guid>
                
                    <category>
                        <![CDATA[ Linux ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtualization ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ David Clinton ]]>
                </dc:creator>
                <pubDate>Wed, 31 Jul 2019 13:00:00 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2019/07/xen-kvm.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Tied up in a AWS announcement about a new EC2 high-end instance type (the C5) is <a target="_blank" href="https://www.theregister.co.uk/2017/11/07/aws_writes_new_kvm_based_hypervisor_to_make_its_cloud_go_faster/">a strong suggestion</a> that Amazon’s cloud computing giant has begun to shift its hundreds of thousands of physical servers away from the open source Xen hypervisor that’s run them until now, to the open source alternative, KVM.</p>
<p>Whether you’ve got your career and/or home mortgage deeply invested in the future of Xen or whether you never knew it existed, you might be interested in learning more about KVM. So here’s a general introduction adapted from my book, <a target="_blank" href="https://www.amazon.com/gp/product/B06XTZ4YWQ/ref=as_li_tl?ie=UTF8&amp;camp=1789&amp;creative=9325&amp;creativeASIN=B06XTZ4YWQ&amp;linkCode=as2&amp;tag=projemun-20&amp;linkId=fa7577d96ed91ffe111b08665bcb53f9">Teach Yourself</a> <a target="_blank" href="https://bootstrap-it.com/index.php/books/">Linux Virtualization and High Availability: prepare for the LPIC-3 304 certification exam</a>.</p>
<blockquote>
<p>_Need some more basic background on either Linux servers or AWS? My <a target="_blank" href="https://www.manning.com/books/linux-in-action?a_aid=bootstrap-it&amp;a_bid=4ca15fc9">Linux in Action</a> and <a target="_blank" href="https://www.manning.com/books/learn-amazon-web-services-in-a-month-of-lunches?a_aid=bootstrap-it&amp;a_bid=1c1b5e27">Learn Amazon Web Services in a Month of Lunches</a> books from Manning might help, along with my <a target="_blank" href="http://pluralsight.pxf.io/c/1191769/424552/7490?subId1=solving&amp;u=https%3A%2F%2Fapp.pluralsight.com%2Fprofile%2Fauthor%2Fdavid-clinton">Linux server administration courses at Pluralsight</a>. There’s also a hybrid course called <a target="_blank" href="https://www.manning.com/livevideo/linux-in-motion?a_aid=bootstrap-it&amp;a_bid=0c56986f&amp;chan=motion1">Linux in Motion</a> that’s made up of more than two hours of video and around 40% of the text of Linux in Action._</p>
</blockquote>
<h2 id="heading-kvm">KVM</h2>
<p>Like Xen, KVM (Kernel-based Virtual Machine) is an open source hypervisor technology for virtualizing compute infrastructure running on x86 compatible hardware. Also like Xen, KVM has both an active user community and significant enterprise deployments.</p>
<p>A KVM host actually runs on the Linux kernel along with two KVM kernel modules (the kvm.ko module and either kvm-intel.ko or kvm-amd.ko). Through its tight kernel integration — including the I/O connectivity with kernel block and network drivers provided by Virtio — KVM can offer its guests more seamless access to all the complex hardware and networking profiles that they might encounter.</p>
<p>Hardware virtualization extensions built into modern CPU designs and required for KVM deployments mean that, right out of the box, KVM guests can safely access only those hardware resources they need without the need to worry about leakage to the larger system.</p>
<p>Where exactly does QEMU fit in with all this? Besides being able to act as a hypervisor, QEMU’s strength is as an emulator. KVM, in its hypervisor virtualization role, can tap on to QEMU’s emulation powers to compliment its own hardware acceleration features, presenting its guests with an emulated chipset and PCI bus. The whole, as they say, can be greater than the sum of its parts.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/07/image-56.png" alt="Image" width="600" height="400" loading="lazy">
<em>A KVM hypervisor sitting between the Linux host OS and its guest VMs</em></p>
<p>A great deal of management functionality for KVM is often actually provided by Libvirt. Therefore, you might sometimes want to refer to the detailed information about KVM-related features like networking, storage, and file system layouts that’s found in the fifth chapter of the <a target="_blank" href="https://www.amazon.com/gp/product/B06XTZ4YWQ/ref=as_li_tl?ie=UTF8&amp;camp=1789&amp;creative=9325&amp;creativeASIN=B06XTZ4YWQ&amp;linkCode=as2&amp;tag=projemun-20&amp;linkId=fa7577d96ed91ffe111b08665bcb53f9">Teach Yourself Linux Virtualization and High Availability</a> book (“Libvirt and Related Tools”).</p>
<h2 id="heading-installation">Installation</h2>
<p>Before anything else, you’ll need to make sure that the physical machine you’re planning to use as a KVM host supports hardware virtualization. Besides the BIOS setting and the contents of /proc/cpuinfo (which we discussed in Chapter One), you can also quickly check this from a running Linux system using kvm-ok:$ kvm-ok</p>
<p>It’s also a good idea to be sure which hardware architecture — 64 or 32-bit — you’re working with:$ uname -m</p>
<p>But even if your hardware profile is up to the task, you’ll have to let the Linux kernel in on your plans. If they’re not already there, you should add the kvm and either kvm-intel or kvm-amd kernel modules.# modprobe kvm-intel</p>
<p>If those modules fail to load (and there’s no /dev/kvm device in the file system), then there’s a good chance your CPU just isn’t up to the job you’d like it to to. However, if all that worked out, you’re ready to install the qemu-kvm package (and, if necessary, libvirt, virt-install, and bridge-utils as well).</p>
<h2 id="heading-working-with-kvm-management-tools">Working with KVM Management Tools</h2>
<p>It’s no secret that virtualization platforms have a well-deserved reputation for being complicated. But there are two things that can make getting started with KVM just a bit more challenging than some of the others:</p>
<ul>
<li>There are quite a few management toolkits available, each offering similar — but not identical — functionality.</li>
<li>They have a nasty habit of changing the names used for the key binaries depending on which distribution and release you’re using.</li>
</ul>
<p>I’ll introduce you to Libvirt Tools and vmbuilder in Chapter Five, but here, we’ll discuss the KVM tool kit.</p>
<p>Building new guests using what we’ll call the “KVM” way is a two step process. First, you’ll use qemu-img to create a new image — or modify or convert an old one. Then you’ll use qemu-kvm to set up a virtual machine that will start up the installation.</p>
<blockquote>
<p>_Did I just say “you’ll use qemu-kvm…”? Silly me. qemu-kvm was merged into qemu a long time ago and has been replaced by qemu-system-x86_64. In the meantime, some systems offer you kvm as a wrapper that executes qemu-system-x86<em>64 -enable-kvm — although you shouldn’t confuse the kvm wrapper with the old kvm binary that used a somewhat different syntax.</em></p>
</blockquote>
<p>So let’s see how these two steps work. You create a disk image with qemu-img (which, by the way, can be used very effectively for other hypervisors as well), where “my-disk” is the name of the image you’d like to create, the maximum size of the image will be 6 GB, and qcow2 is the file format. qcow, by the way, stands for “QEMU Copy On Write”.</p>
<pre><code>qemu-img create -f qcow2 /home/username/myimages/my-disk.img <span class="hljs-number">6</span>G \
 Formatting ‘/home/username/myimages/my-disk.img’, \
 fmt=qcow2 size=<span class="hljs-number">6442450944</span> \
 encryption=off \
 cluster_size=<span class="hljs-number">65536</span> \
 lazy_refcounts=off \
 refcount_bits=<span class="hljs-number">16</span>
</code></pre><p>Choosing a file format will depend on your specific needs. If you need greater compatibility and flexibility — including the ability to generate sophisticated snapshots — then qcow2 is probably going to be your best choice.</p>
<p>The qcow disk image format permits disk space allocation to grow only as needed, meaning the use of space is always as efficient as possible. Changes to a qcow read-only image can be saved to a separate file, which refers internally to the original image. qcow2 added the ability to create multiple image snapshots.</p>
<p>We’re now ready for step two. Here’s how we’ll build our VM:</p>
<pre><code>kvm -name my-VM \
 -hda /home/username/myimages/my-disk.img \
 -cdrom /home/username/Downloads/ubuntu<span class="hljs-number">-16.04</span>-server-amd64.iso \
 -boot d -m <span class="hljs-number">1024</span>
</code></pre><p>A new SDL window will often (although not necessarily for all distributions) pop up where you can complete the operating system installation process. Regaining control of your mouse from the Qemu terminal requires pressing CTRL+ALT.</p>
<p>To explain: using “kvm” (although the precise command you’ll need for your version may differ), we’ll call our new guest “my-VM”, designate the my-disk.img file as hda (“hard drive a”), point to the location of the operating system ISO (Ubuntu 16.04 server, in this case), and set 1024 MB as the maximum memory alloted to the VM.</p>
<p>By default, KVM will configure your guest for user-level networking (as though the parameters -netdev user,id=user.0 -device e1000,netdev=user.0 were specified). This will provide the guest with an IP address through KVM’s own DHCP service and access to your host, the Internet, and to LAN-based recourses. While the default configuration is simple, it may be overly restrictive for some scenarios, as there are often some performance and feature limitations.</p>
<p>Besides these, you can use command line flags to control various VM configuration parameters, including:</p>
<ul>
<li>-smp 2 provides two processors (“smp” = symmetric multiprocessing).</li>
<li>The -net argument (example: -net nic,model=virtio,macaddr =52:54:00:05:11:11) establishes a network connection for your guest.</li>
<li>You can provision a network bridge using something like -net bridge,vlan=0,br=br0 — although this will require a matching -net definition on the host. The two are connected through a special “vlan” parameter.</li>
<li>-balloon virtio will allow me to expand or reduce a guest’s memory size without having to reboot it.</li>
<li>You can also use the -drive file= flag to define additional block storage devices. Adding a value for format= (qcow2, for instance).</li>
</ul>
<p>The -M flag will assign a specific machine type hardware emulation. pc. For example, will provide a standard PC profile. For a complete list of available machine types, you can run kvm -M ?:</p>
<pre><code>kvm -M ?
Supported machines are:
ubuntu Ubuntu <span class="hljs-number">15.04</span> PC (i440FX + PIIX, <span class="hljs-number">1996</span>) (alias <span class="hljs-keyword">of</span> pc-i440fx-wily)
pc-i440fx-wily Ubuntu <span class="hljs-number">15.04</span> PC (i440FX + PIIX, <span class="hljs-number">1996</span>) (<span class="hljs-keyword">default</span>)
ubuntu Ubuntu <span class="hljs-number">15.04</span> PC (i440FX + PIIX, <span class="hljs-number">1996</span>) (alias <span class="hljs-keyword">of</span> pc-i440fx-vivid)
pc-i440fx-vivid Ubuntu <span class="hljs-number">15.04</span> PC (i440FX + PIIX, <span class="hljs-number">1996</span>) (<span class="hljs-keyword">default</span>)
pc-i440fx-utopic Ubuntu <span class="hljs-number">14.10</span> PC (i440FX + PIIX, <span class="hljs-number">1996</span>)
pc-i440fx-trusty Ubuntu <span class="hljs-number">14.04</span> PC (i440FX + PIIX, <span class="hljs-number">1996</span>)
pc Standard PC (i440FX + PIIX, <span class="hljs-number">1996</span>) (alias <span class="hljs-keyword">of</span> pc-i440fx<span class="hljs-number">-2.5</span>)
pc-i440fx<span class="hljs-number">-2.5</span> Standard PC (i440FX + PIIX, <span class="hljs-number">1996</span>)
pc-i440fx<span class="hljs-number">-2.4</span> Standard PC (i440FX + PIIX, <span class="hljs-number">1996</span>)
pc-i440fx<span class="hljs-number">-2.3</span> Standard PC (i440FX + PIIX, <span class="hljs-number">1996</span>)
pc-i440fx<span class="hljs-number">-2.2</span> Standard PC (i440FX + PIIX, <span class="hljs-number">1996</span>)
pc-i440fx<span class="hljs-number">-2.1</span> Standard PC (i440FX + PIIX, <span class="hljs-number">1996</span>)
pc-i440fx<span class="hljs-number">-2.0</span> Standard PC (i440FX + PIIX, <span class="hljs-number">1996</span>)
pc-i440fx<span class="hljs-number">-1.7</span> Standard PC (i440FX + PIIX, <span class="hljs-number">1996</span>)
pc-i440fx<span class="hljs-number">-1.6</span> Standard PC (i440FX + PIIX, <span class="hljs-number">1996</span>)
pc-i440fx<span class="hljs-number">-1.5</span> Standard PC (i440FX + PIIX, <span class="hljs-number">1996</span>)
pc-i440fx<span class="hljs-number">-1.4</span> Standard PC (i440FX + PIIX, <span class="hljs-number">1996</span>)
pc<span class="hljs-number">-1.3</span> Standard PC (i440FX + PIIX, <span class="hljs-number">1996</span>)
pc<span class="hljs-number">-1.2</span> Standard PC (i440FX + PIIX, <span class="hljs-number">1996</span>)
pc<span class="hljs-number">-1.1</span> Standard PC (i440FX + PIIX, <span class="hljs-number">1996</span>)
pc<span class="hljs-number">-1.0</span> Standard PC (i440FX + PIIX, <span class="hljs-number">1996</span>)
pc<span class="hljs-number">-0.15</span> Standard PC (i440FX + PIIX, <span class="hljs-number">1996</span>)
pc<span class="hljs-number">-0.14</span> Standard PC (i440FX + PIIX, <span class="hljs-number">1996</span>)
pc<span class="hljs-number">-0.13</span> Standard PC (i440FX + PIIX, <span class="hljs-number">1996</span>)
pc<span class="hljs-number">-0.12</span> Standard PC (i440FX + PIIX, <span class="hljs-number">1996</span>)
pc<span class="hljs-number">-0.11</span> Standard PC (i440FX + PIIX, <span class="hljs-number">1996</span>)
pc<span class="hljs-number">-0.10</span> Standard PC (i440FX + PIIX, <span class="hljs-number">1996</span>)
q35 Standard PC (Q35 + ICH9, <span class="hljs-number">2009</span>) (alias <span class="hljs-keyword">of</span> pc-q35–<span class="hljs-number">2.5</span>)
pc-q35–<span class="hljs-number">2.5</span> Standard PC (Q35 + ICH9, <span class="hljs-number">2009</span>)
pc-q35–<span class="hljs-number">2.4</span> Standard PC (Q35 + ICH9, <span class="hljs-number">2009</span>)
pc-q35–<span class="hljs-number">2.3</span> Standard PC (Q35 + ICH9, <span class="hljs-number">2009</span>)
pc-q35–<span class="hljs-number">2.2</span> Standard PC (Q35 + ICH9, <span class="hljs-number">2009</span>)
pc-q35–<span class="hljs-number">2.1</span> Standard PC (Q35 + ICH9, <span class="hljs-number">2009</span>)
pc-q35–<span class="hljs-number">2.0</span> Standard PC (Q35 + ICH9, <span class="hljs-number">2009</span>)
pc-q35–<span class="hljs-number">1.7</span> Standard PC (Q35 + ICH9, <span class="hljs-number">2009</span>)
pc-q35–<span class="hljs-number">1.6</span> Standard PC (Q35 + ICH9, <span class="hljs-number">2009</span>)
pc-q35–<span class="hljs-number">1.5</span> Standard PC (Q35 + ICH9, <span class="hljs-number">2009</span>)
pc-q35–<span class="hljs-number">1.4</span> Standard PC (Q35 + ICH9, <span class="hljs-number">2009</span>)
isapc ISA-only PC
none empty machine
xenfv Xen Fully-virtualized PC
xenpv Xen Para-virtualized PC
</code></pre><h2 id="heading-kvm-monitor">KVM Monitor</h2>
<p>While working with QEMU, you can open a monitor console and interact with your clients in ways that might be difficult or even impossible using a regular headless server. You can launch the KVM Monitor by pressing CTRL+ALT, and then SHIFT+2, and a new console will open on your desktop. SHIFT+1 will close the console. You can also access the console from the command line using something like:</p>
<pre><code>kvm -monitor stdio
</code></pre><p>You will probably NOT be able to launch the monitor as root (i.e., via sudo). Naturally, your version may require “qemu-system-x86_64” rather than kvm. This approach allows you to add command line arguments (like that -monitor which specified a console target). Consult man qemu-system-x86_64 for details on the kinds of operations the monitor allows.</p>
<p>This example (borrowed from en.wikibooks.org/wiki/QEMU/Monitor) will list all the block devices currently available to your system, and then point one of them to an ISO file you want to use:</p>
<pre><code>(qemu) info block
ide0-hd0: type=hd removable=<span class="hljs-number">0</span> file=<span class="hljs-regexp">/path/</span>to/winxp.img
ide0-hd1: type=hd removable=<span class="hljs-number">0</span> file=<span class="hljs-regexp">/path/</span>to/pagefile.raw
ide1-hd1: type=hd removable=<span class="hljs-number">0</span> file=<span class="hljs-regexp">/path/</span>to/testing_data.img
ide1-cd0: type=cdrom removable=<span class="hljs-number">1</span> locked=<span class="hljs-number">0</span> file=<span class="hljs-regexp">/dev/</span>sr0 ro=<span class="hljs-number">1</span> drv=host_device
<span class="hljs-attr">floppy0</span>: type=floppy removable=<span class="hljs-number">1</span> locked=<span class="hljs-number">0</span> [not inserted]
<span class="hljs-attr">sd0</span>: type=floppy removable=<span class="hljs-number">1</span> locked=<span class="hljs-number">0</span> [not inserted]
(qemu) change ide1-cd0 /home/images/my.iso
</code></pre><h2 id="heading-networking">Networking</h2>
<p>By default, a KVM guest will receive an IP address within the 10.0.2.0/24 subnet, and have outgoing access (including SSH access) both to its host, and to the wider network beyond. By that same default however, it won’t be able to host services for network clients. If you need to open up incoming network connectivity, you’ll probably want to create a network bridge on your host that’s similar to the one we used for Xen in the previous chapter. As before, you will install bridge-utils on the host and, assuming you’re running a Debian-based system and you want your host to receive its IP from a network DHCP server, edit the /etc/network/interfaces to look something like this (on CentOS machines, edit files in the /etc/sysconfig/network-scripts/ directory):</p>
<pre><code>auto lo
iface lo inet loopback
auto eth0
iface eth0 inet manual
auto br0
iface br0 inet dhcp
 bridge_ports eth0
 bridge_stp off
 bridge_fd <span class="hljs-number">0</span>
 bridge_maxwait <span class="hljs-number">0</span>
</code></pre><p>On CentOS, you’ll need to create an ifcfg-br0 file in the /etc/sysconfig/network-scripts/ directory to look something like this:</p>
<pre><code>DEVICE=br0
TYPE=Bridge
BOOTPROTO=<span class="hljs-keyword">static</span>
DNS1=<span class="hljs-number">192.168</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span>
GATEWAY=<span class="hljs-number">192.168</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span>
IPADDR=<span class="hljs-number">192.168</span><span class="hljs-number">.0</span><span class="hljs-number">.100</span>
NETMASK=<span class="hljs-number">255.255</span><span class="hljs-number">.255</span><span class="hljs-number">.0</span>
ONBOOT=yes
SEARCH=”example.com”
</code></pre><p>…And then add a line reading BRIDGE=br0 line to your primary network interface file (which will often be: /etc/sysconfig/network-scripts/ifcfg-eth0).</p>
<p>You will then stop and restart your network services (or reboot).</p>
<p><em>Looking for a solid introduction to Linux or AWS administration? Check out my</em> <a target="_blank" href="https://www.manning.com/books/linux-in-action?a_aid=bootstrap-it&amp;a_bid=4ca15fc9"><em>Linux in Action</em></a> <em>and</em> <a target="_blank" href="https://www.manning.com/books/learn-amazon-web-services-in-a-month-of-lunches?a_aid=bootstrap-it&amp;a_bid=1c1b5e27"><em>Learn Amazon Web Services in a Month of Lunches</em></a> <em>books and the</em> <a target="_blank" href="https://www.manning.com/livevideo/linux-in-motion?a_aid=bootstrap-it&amp;a_bid=0c56986f&amp;chan=motion1"><em>Linux in Motion</em></a> <em>text-video hybrid course from Manning. Prefer your tech learning in video? I’ve got</em> <a target="_blank" href="http://pluralsight.pxf.io/c/1191769/424552/7490?subId1=solving&amp;u=https%3A%2F%2Fapp.pluralsight.com%2Fprofile%2Fauthor%2Fdavid-clinton"><em>Linux administration courses at Pluralsight</em></a> <em>just waiting to be watched.</em></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ An in-depth introduction to Docker on AWS ]]>
                </title>
                <description>
                    <![CDATA[ Container virtualization — most visibly represented by Docker — is a server paradigm that will likely drive enterprise computing for years to come. The Cloud is the most obvious and logical platform for containerdeployment. Amazon Web Services largel... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/an-in-depth-introduction-to-docker-on-aws-f373ff97da0e/</link>
                <guid isPermaLink="false">66b9959d3cd81de09c96b282</guid>
                
                    <category>
                        <![CDATA[ AWS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Docker ]]>
                    </category>
                
                    <category>
                        <![CDATA[ software development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tech  ]]>
                    </category>
                
                    <category>
                        <![CDATA[ virtualization ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ David Clinton ]]>
                </dc:creator>
                <pubDate>Mon, 12 Mar 2018 07:11:50 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*6kZO8kBIc4hQPRYS-Q47nQ.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Container virtualization — most visibly represented by Docker — is a server paradigm that will likely drive enterprise computing for years to come.</p>
<p>The Cloud is the most obvious and logical platform for container<br>deployment.</p>
<p>Amazon Web Services largely dominates the cloud computing world. Add it up. If you’re interested in getting a piece of all this action, you’ll definitely want to figure out how it all works.</p>
<p>First, though, let’s quickly define some key terms.</p>
<h3 id="heading-virtualization">Virtualization</h3>
<p>Virtualization is the division of physical computer and networking resources into smaller, more flexible units, presenting these smaller units to users as though each was a discrete resource.</p>
<p>The idea is that, instead of assigning specific computing tasks to individual physical servers — which may sometimes end up being over- or underused — a single physical server can be logically divided into as few or as many virtual servers as needed.</p>
<p>That means, as the figure below illustrates, there can be dozens of individually installed operating systems (OS) running side by side on the same hard drive. Each OS is effectively unaware that it isn’t all alone in its local environment.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/UpeA5JtZvRnCwwCFTP-3hgd2X2-8HI0Or2zb" alt="Image" width="800" height="479" loading="lazy">
<em>Multiple applications being served through physical servers or, via VMs, from a single virtualization server</em></p>
<p>Practically, each operating system instance can be accessed remotely by both administrators and customers in exactly the same way as any other server.</p>
<p>In this kind of environment, as soon as your virtual server completes its task or becomes unnecessary, you can instantly delete it. This will free up the resources it was using for the next task in the queue.</p>
<p>There’s no need to over-provision virtual servers to anticipate possible future needs, because future needs can be easily met whenever they arrive.</p>
<p>In fact, today’s virtual server might only live a few minutes or even seconds before, having completed its task, being shut down for good to make room for whatever’s next. All this allows for far more efficient use of expensive hardware. It provides the ability to provision and launch new servers at will, either to test new configurations or add fresh power to your production services.</p>
<p>Cloud computing providers like AWS use virtualized computers of one kind or another. The hundreds of thousands of <a target="_blank" href="https://aws.amazon.com/ec2/">Amazon EC2</a> instances, for example, all run on top of the open source <a target="_blank" href="https://www.xenproject.org/">Xen</a> or <a target="_blank" href="https://www.linux-kvm.org/page/Main_Page">KVM</a> <a target="_blank" href="https://en.wikipedia.org/wiki/Hypervisor">hypervisors</a> — which are themselves installed and running on many thousands of physical servers maintained in Amazon’s vast server farms.</p>
<p>Whatever hypervisor technology is being used, the goal is to provide a largely automated hosting environment for multiple complete, self-contained virtual computers.</p>
<p>Containers like Docker, on the other hand, aren’t standalone virtual machines but are modified file systems sharing the operating system kernel of their physical host. That’s what we’ll discuss next.</p>
<h3 id="heading-containers">Containers</h3>
<p>What are containers? Well, for one thing, they’re not hypervisors. Instead, they’re extremely lightweight virtual servers that, as you can see from the figure, rather than running as full operating systems, share the underlying kernel of their host OS.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/QEQeIyqAUN6Zk-KrvglUlbU6gjEW1s32MIZT" alt="Image" width="800" height="479" loading="lazy">
<em>Virtualized containers running with access to their host’s kernel and hardware resources</em></p>
<p>Containers can be built from plain-text scripts, created and launched in seconds, and easily and reliably shared across networks. Container technologies include the <a target="_blank" href="https://linuxcontainers.org/">Linux Container</a> project, which was Docker’s original inspiration.</p>
<p>The script-friendly container design makes it easy to automate and remotely manage complex clusters of containers, often deployed as microservices.</p>
<p>Microservices is a compute services architecture where multiple containers are deployed, each with a distinct yet complementary role. You might, therefore, launch one container as a database back-end, another as a file server, and a third as a web server.</p>
<h4 id="heading-docker">Docker</h4>
<p>As I explore in <a target="_blank" href="http://pluralsight.pxf.io/c/1191769/424552/7490?subId1=solving&amp;u=https%3A%2F%2Fapp.pluralsight.com%2Fprofile%2Fauthor%2Fdavid-clinton">one or two of my Pluralsight courses</a>, a Docker container is an image whose behavior is defined by a script. The container is launched as a software process that’s cunningly disguised as a server.</p>
<p>But what’s an image? It’s a software file containing a snapshot of a full operating system file system. Everything necessary to launch a viable virtual server is included.</p>
<p>An image might consist of just a base operating system like Ubuntu Linux, or the tiny and super-fast Alpine Linux. But an image could also include additional layers with software applications like web servers and databases. No matter how many layers an image has and how complicated the relationships between them might be, the image itself never changes.</p>
<p>When, as shown in the next figure, an image is launched as a container, an extra writable layer is automatically added into which the record of any ongoing system activity is saved.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/HoFgA8qtjPi3GFm8SWES3O33X0RfM8S3Vgrh" alt="Image" width="800" height="479" loading="lazy">
<em>A simple MySQL/Ubuntu Docker image illustrated with its writable data layer</em></p>
<p>What do folks commonly do with their Docker containers? Often, they’ll load up some kind of app development project to test how it will work, and then share it with team members for feedback and updates. When the app is complete, it can be launched as a cluster of containers (or “swarm” as Docker calls it) that can be programmatically and instantly scaled up or down according to user demand.</p>
<p>While Docker is a Linux-based technology and requires a Linux kernel to run, running remote or even local Docker containers on Mac or Windows machines is possible through either the Docker for Mac or Docker for Windows apps or for older machines, through the Docker Machine tool.</p>
<h3 id="heading-cloud-computing">Cloud computing</h3>
<p>Cloud computing is the provision of on-demand, self-service compute, memory, and storage resources remotely over a network.</p>
<p>Since cloud-based services are billed in very small increments, you can quickly configure and launch a wide range of projects. And since the resources are all virtual, launching them as part of an experiment or to solve some short-term problem will often make lots of sense. When the work’s all done, the resource is shut down.</p>
<p>Cloud platforms let you do things that would be impossible — or impossibly expensive — anywhere else.</p>
<p>Unsure how long your project will run or how much demand it will attract? Perhaps purchasing, building, and housing all the expensive hardware you’d need to properly support your project in-house can’t be justified.</p>
<p>Investing heavily in server, cooling, and routing equipment might just not make sense.</p>
<p>But if you could rent just enough of someone else’s equipment to match fast-changing demand levels and pay only for what you actually use, then it might work.</p>
<h3 id="heading-aws">AWS</h3>
<p>There’s no shortage of ways to manage Docker containers on AWS. In fact, between frameworks, orchestration interfaces, image repositories,<br>and hybrid solutions, the variety can get confusing.</p>
<p>This article won’t dive deeply into every option, but you should at least be aware of all your choices:</p>
<p>Amazon’s <a target="_blank" href="https://aws.amazon.com/ecs/">EC2 Container Service</a> (ECS) leverages specially configured EC2 instances as hosts for integrated Docker containers. You don’t have to get your hands dirty on the EC2 instance itself, as you can provision and administrate your containers through the ECS framework. ECS now offers greater abstraction (and simplicity) through their Fargate mode option.</p>
<p><a target="_blank" href="https://aws.amazon.com/cloudformation/">AWS CloudFormation</a> allows you to configure any combination of AWS resources into a template that can be deployed one or many times. You can include specified dependencies and custom parameters in the template. Given its self-contained and scriptable design, CloudFormation is a natural environment for Docker deployments. In fact, Docker itself offers its Docker for AWS service (currently in beta), that will automatically generate a CloudFormation template to orchestrate a swarm of Docker containers to run on AWS infrastructure within your account.</p>
<p><a target="_blank" href="https://aws.amazon.com/elasticbeanstalk/">AWS Elastic Beanstalk</a> effectively sits on top of ECS. It allows you to deploy your application across all the AWS resources normally used by ECS, but with virtually all of the logistics neatly abstracted away. Effectively, all you need in order to launch a fully scalable, complex microservices environment is a declarative JSON-formatted script in a file called <code>Dockerrun.aws.json</code>. You can either upload your script to the GUI or, from an initialized local directory using the AWS Beanstalk CLI.</p>
<p><a target="_blank" href="https://aws.amazon.com/eks/">Amazon Elastic Container Service for Kubernetes</a> (EKS) is currently still in preview. It’s a tool allowing you to manage containers using the open source Kubernetes orchestrator, but without having to install your own clusters. Like ECS, EKS will deploy all the necessary AWS infrastructure for your clusters without manual intervention.</p>
<p><a target="_blank" href="https://www.docker.com/docker-aws">Docker for AWS</a> is, at the time of writing, still in beta. Using its browser interface, you can use the service to install and run a “swarm of Docker Engines” that are fully integrated with AWS infrastructure services like auto scaling, load balancing (ELB), and block storage.</p>
<p>Docker Datacenter (now marketed as part of <a target="_blank" href="https://www.docker.com/enterprise-edition">Docker Enterprise Edition</a>) is a joint AWS/Docker project that provides commercial customers with a more customizable interface for integrating Docker with AWS, Azure, and IBM infrastructures.</p>
<p><a target="_blank" href="https://cloud.docker.com/">Docker Cloud</a>, much like Docker Datacenter, offers a GUI, browser-based console for managing all aspects of your Docker deployments. This includes administration for your host nodes running in public clouds. The big difference is that, unlike Datacenter, the Docker Cloud administration service is hosted from its own site. There’s no server software to install on your own equipment.</p>
<p><a target="_blank" href="https://hub.docker.com/">Docker Hub</a> is probably the obvious first place to look for and to share Docker images. Provided by Docker itself, Docker Hub holds a vast collection of images that come pre-loaded to support all kinds of application projects. You can find and research images on the hub.docker.com web site, and then pull them directly into your own Docker Engine environment.</p>
<p><a target="_blank" href="https://aws.amazon.com/ecr/">EC2 Container Registry</a> (ECR) is Amazon’s own image registry to go with their EC2 Container Service platform. Images can be pushed, pulled, and managed through the AWS GUI or CLI tool. Permissions policies can closely control image access only to the people you select.</p>
<p>I think you’re ready to start. If you haven’t yet, do head over to the<br>Amazon Web Services site to create an AWS account. In case you’re not yet familiar with how this all works, new accounts get a generous full year of experimentation with any service level that’s eligible for the Free Tier. Assuming you’re still in your first year, nothing we’re going to do in this course should cost you a penny.</p>
<p>Next, we’ll pop the lid off Docker and see how it works at its most basic level: your laptop command line. Technically, this has very little relevance to AWS workloads, but it’ll be a great way to better understand the workflow.</p>
<h3 id="heading-introduction-to-docker">Introduction to Docker</h3>
<p>Properly visualizing how all the many AWS parts work will probably be easier if you first understand what’s going on under the hood with Docker itself. So in this article I’ll walk you through launching and configuring a simple Docker container on my local workstation.</p>
<p>Ready to go?</p>
<h4 id="heading-the-docker-command-line">The Docker command line</h4>
<p>Let’s see how this thing actually works. I’m going to get Docker up and running on my local workstation and then test it out with a quick hello-world operation. I will then pull a real working Ubuntu image and run it.</p>
<p>I won’t go through the process of installing Docker on your machine here for a few reasons. First of all, the specifics will vary greatly depending on the operating system you’re running. But they’re also likely to frequently change, so anything I write here will probably be obsolete within a short while. And finally, none of this is all that relevant to AWS. Check out Docker’s own instructions at <a target="_blank" href="https://docs.docker.com/install">docs.docker.com/install</a>.</p>
<p>Along the way I’ll try out some of Docker’s command line tools, including creating a new network interface and associating a container with it. This is the kind of environment configuration that can be very useful for real-world deployments involving multiple tiers of resources that need to be logically separated.</p>
<p>Most Linux distributions now use <a target="_blank" href="https://www.freedesktop.org/wiki/Software/systemd/">systemd</a> via the <a target="_blank" href="https://www.freedesktop.org/software/systemd/man/systemctl.html">systemctl</a> command to handle processes. In this case <code>systemctl start docker</code> will launch the Docker daemon if it’s not already running. <code>systemctl status docker</code> will return some useful information, including in-depth error messages if something has gone wrong. In this case, everything looks healthy.</p>
<pre><code># systemctl start docker# systemctl status docker
</code></pre><p>That’s the only Linux-specific bit. From here on in we’ll be using commands that’ll work anywhere Docker’s properly installed.</p>
<h4 id="heading-launch-a-container">Launch a container</h4>
<p>Running commands from the Docker command line always begins with the word “docker”. The normal first test of a newly installed system is to<br>use <code>docker run</code> to launch a small image — the purpose-built “hello-world” image in this case.</p>
<p>As you can tell from the output below, Docker first looked for the image on the local system. Docker is particularly efficient in that way. It will always try to reuse locally available elements before turning to remote sources.</p>
<p>In this case, since there are no existing images in this new environment, Docker goes out to pull hello-world from the official Docker library.</p>
<pre><code class="lang-docker">$ docker <span class="hljs-keyword">run</span><span class="bash"> hello-world</span>
Unable to find image ‘hello-world:latest’ locally
latest: Pulling <span class="hljs-keyword">from</span> library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:<span class="hljs-number">66</span>ef312bbac49c39a89aa9bcc3cb4f3c9e7de3788c9
<span class="hljs-number">44158</span>df3ee0176d32b751
Status: Downloaded newer image for hello-world:latest2.<span class="hljs-number">1</span>. 
Hello <span class="hljs-keyword">from</span> Docker!
This message shows that your installation appears to be
working correctly. To generate this message, Docker took the
following steps:
<span class="hljs-number">1</span>. The Docker client contacted the Docker daemon.
<span class="hljs-number">2</span>. The Docker daemon pulled the “hello-world” image
<span class="hljs-keyword">from</span> the Docker Hub. (amd64)
<span class="hljs-number">3</span>. The Docker daemon created a new container <span class="hljs-keyword">from</span> that
image which runs the executable that produces the output you
are currently reading.
<span class="hljs-number">4</span>. The Docker daemon streamed that output to the Docker client,
which sent it to your terminal.
To try something more ambitious, you can <span class="hljs-keyword">run</span><span class="bash"> an Ubuntu container</span>
with:
$ docker <span class="hljs-keyword">run</span><span class="bash"> -it ubuntu bash</span>
Share images, automate workflows, and more with a free Docker ID:
https://cloud.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
</code></pre>
<p>The full output of this command includes a useful four part description of what just happened. The Docker client contacted the Docker daemon which proceeded to download the hello-world image from the repository. The image is converted to a running container by the docker run command whose output is streamed to our command line shell — the Docker client.</p>
<p>Let me break that jargon down for you just a bit:</p>
<ul>
<li><strong>Docker client</strong> — the command line shell activated by running docker<br>commands</li>
<li><strong>Docker daemon</strong> — the local Docker process we started just before<br>with the <code>systemctl</code> command</li>
<li><strong>Image</strong> — a file containing the data that will be used to make up an<br>operating system</li>
</ul>
<p>Typing just <code>docker</code> will print a useful list of common commands along<br>with brief descriptions, and d<code>ocker info</code> will return information about<br>the current state of our Docker client.</p>
<p>Notice how we’ve currently got one container and one image (the hello-world container) and that there are zero containers running right now.</p>
<pre><code class="lang-docker">$ docker info
Containers: <span class="hljs-number">1</span>
Running: <span class="hljs-number">0</span>
Paused: <span class="hljs-number">0</span>
Stopped: <span class="hljs-number">1</span>
Images: <span class="hljs-number">3</span>
Server Version: <span class="hljs-number">1.13</span>.<span class="hljs-number">1</span>
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: <span class="hljs-number">28</span>
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
<span class="hljs-keyword">Volume</span><span class="bash">: <span class="hljs-built_in">local</span></span>
Network: bridge host macvlan null overlay
</code></pre>
<h4 id="heading-interactive-container-sessions">Interactive container sessions</h4>
<p>Let’s try out the “more ambitious” <code>docker run -it ubuntu bash</code> command that the Docker documentation previously suggested. This will download the latest official base Ubuntu image and run it as a container.</p>
<p>The <code>-i</code> option will make the session interactive, meaning you’ll be dropped into a live shell within the running container where you’ll be able to control things like you would on any other server. The <code>-t</code> argument will open a TTY shell.</p>
<pre><code class="lang-docker">$ docker <span class="hljs-keyword">run</span><span class="bash"> -it ubuntu bash</span>
Unable to find image ‘ubuntu:latest’ locally
latest: Pulling <span class="hljs-keyword">from</span> library/ubuntu
<span class="hljs-number">1</span>be7f2b886e8: Pull complete
<span class="hljs-number">6</span>fbc4a21b806: Pull complete
c71a6f8e1378: Pull complete
<span class="hljs-number">4</span>be3072e5a37: Pull complete
<span class="hljs-number">06</span>c6d2f59700: Pull complete
Digest: sha256:e27e9d7f7f28d67aa9e2d7540bdc2b33254
b452ee8e60f388875e5b7d9b2b696
Status: Downloaded newer image for ubuntu:latest
root@c81a051f6f03:/<span class="hljs-comment">#</span>
</code></pre>
<p>Note the new command line prompt <code>root@c81a051f6f03:/#</code>. We’re<br>now actually inside a minimal but working Docker container.</p>
<p>We can, for instance, update our software repository indexes .</p>
<pre><code># ls
bin dev home lib64 mnt proc run srv tmp <span class="hljs-keyword">var</span> boot etc lib media opt root sbin sys usr
# apt update
<span class="hljs-attr">Get</span>:<span class="hljs-number">1</span> http:<span class="hljs-comment">//security.ubuntu.com/ubuntu xenial-security InRelease</span>
Get:<span class="hljs-number">2</span> http:<span class="hljs-comment">//archive.ubuntu.com/ubuntu xenial InRelease</span>
[…]
Fetched <span class="hljs-number">24.8</span> MB <span class="hljs-keyword">in</span> <span class="hljs-number">48</span>s (<span class="hljs-number">515</span> kB/s)
Reading package lists… Done
Building dependency tree
Reading state information… Done
<span class="hljs-number">6</span> packages can be upgraded. Run ‘apt list — upgradable’ to
see them.
</code></pre><p>If I exit the container, it will shut down and I’ll find myself back in my host server. Typing <code>docker info</code> once more now shows me two stopped containers rather than just one.</p>
<pre><code>$ docker infoContainers: <span class="hljs-number">2</span>Running: <span class="hljs-number">0</span>Paused: <span class="hljs-number">0</span>Stopped: <span class="hljs-number">2</span>Images: <span class="hljs-number">4</span>[…]
</code></pre><h4 id="heading-running-containers-in-the-background">Running containers in the background</h4>
<p>I could launch a container in the background by adding the <code>detach=true</code> option which will return a container ID. Listing all active docker containers with <code>ps</code> will then show me my new <strong>running</strong> container.</p>
<pre><code>$ docker info
<span class="hljs-attr">Containers</span>: <span class="hljs-number">2</span>
<span class="hljs-attr">Running</span>: <span class="hljs-number">0</span>
<span class="hljs-attr">Paused</span>: <span class="hljs-number">0</span>
<span class="hljs-attr">Stopped</span>: <span class="hljs-number">2</span>
<span class="hljs-attr">Images</span>: <span class="hljs-number">4</span>
[…]
</code></pre><h4 id="heading-managing-containers">Managing containers</h4>
<p>As you can see from the <code>wizardly_pasteur</code> name, the people who designed Docker compiled a rather eccentric pool of names to assign to your containers. If you’d like to rename a container — perhaps so managing it will require less typing — run <code>docker rename</code>, followed by the current container name and the new name you’d like to give it. I’ll run <code>docker ps</code> once again to show the update in action.</p>
<pre><code class="lang-js">$ docker rename wizardly_pasteur MyContainer
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES
<span class="hljs-number">232</span>a83013d39 ubuntu “bash” <span class="hljs-number">3</span> minutes ago Up <span class="hljs-number">5</span> minutes MyContainer
</code></pre>
<p><code>docker inspect</code> followed by a container name, will return pages and pages of useful information about that container’s configuration and environment. The output snippet I’ve included below displays the container’s network environment details. Note that the network gateway is <code>172.17.0.1</code> and the container’s actual IP address is <code>172.17.0.2</code> — that will be useful later.</p>
<pre><code>$ docker inspect MyContainer
[...]
            <span class="hljs-string">"Gateway"</span>: <span class="hljs-string">"172.17.0.1"</span>,
            <span class="hljs-string">"GlobalIPv6Address"</span>: <span class="hljs-string">""</span>,
            <span class="hljs-string">"GlobalIPv6PrefixLen"</span>: <span class="hljs-number">0</span>,
            <span class="hljs-string">"IPAddress"</span>: <span class="hljs-string">"172.17.0.2"</span>,
            <span class="hljs-string">"IPPrefixLen"</span>: <span class="hljs-number">16</span>,
            <span class="hljs-string">"IPv6Gateway"</span>: <span class="hljs-string">""</span>,
            <span class="hljs-string">"MacAddress"</span>: <span class="hljs-string">"02:42:ac:11:00:02"</span>,
            <span class="hljs-string">"Networks"</span>: {
                <span class="hljs-string">"bridge"</span>: {
                    <span class="hljs-string">"IPAMConfig"</span>: <span class="hljs-literal">null</span>,
                    <span class="hljs-string">"Links"</span>: <span class="hljs-literal">null</span>,
                    <span class="hljs-string">"Aliases"</span>: <span class="hljs-literal">null</span>,
[...]
</code></pre><h4 id="heading-docker-networks">Docker networks</h4>
<p><code>docker network ls</code> will list all the network interfaces currently associated with our Docker client. Note in particular the <code>bridge</code> interface which connects a container to the Docker <code>host</code>, allowing network communication into and out of the container.</p>
<pre><code>$ docker network ls
NETWORK ID          NAME            DRIVER        SCOPE
fa4da6f158de        bridge          bridge        local
<span class="hljs-number">18385</span>f695b4e        host            host          local
<span class="hljs-number">6</span>daa514c5756        none            <span class="hljs-literal">null</span>          local
</code></pre><p>We can create a new network interface by running <code>docker network create</code> followed by the name we’d like to give our new interface. Running <code>inspect</code> against the new interface shows us — through the <code>Driver</code> value — that this new interface has been automatically associated with the network <code>bridge</code> we saw earlier, but exists on its own <code>172.18.0.x</code> network. You’ll remember that our default network used <code>172.17.0.x</code>.</p>
<pre><code>$ docker network create newNet
<span class="hljs-number">715</span>f775551522c43104738dfc2043b66aca6f2946919b39ce
<span class="hljs-number">06961</span>f3f86e33bb
$ docker network inspect newNet
[
    {
        <span class="hljs-string">"Name"</span>: <span class="hljs-string">"newNet"</span>,
 [...]
        <span class="hljs-string">"Scope"</span>: <span class="hljs-string">"local"</span>,
        <span class="hljs-string">"Driver"</span>: <span class="hljs-string">"bridge"</span>,
        <span class="hljs-string">"EnableIPv6"</span>: <span class="hljs-literal">false</span>,
        <span class="hljs-string">"IPAM"</span>: {
            <span class="hljs-string">"Driver"</span>: <span class="hljs-string">"default"</span>,
            <span class="hljs-string">"Options"</span>: {},
            <span class="hljs-string">"Config"</span>: [
                {
                    <span class="hljs-string">"Subnet"</span>: <span class="hljs-string">"172.18.0.0/16"</span>,
                    <span class="hljs-string">"Gateway"</span>: <span class="hljs-string">"172.18.0.1"</span>
 [...]
]
</code></pre><p>Confused? My Solving for Technology book has a <a target="_blank" href="https://learntech.bootstrap-it.com/chapter7.html">chapter on basic TCP/IP networking</a>.</p>
<h4 id="heading-moving-containers-between-networks">Moving containers between networks</h4>
<p>You might sometimes want to move an existing container from one network to another — perhaps you need to reorganize and better secure your resources. Try it out by moving that Ubuntu container to a different network, like the <code>newNet</code> interface we just created. Use <code>docker network connect</code> followed by the network name <code>newNet</code> and then the container name <code>MyContainer</code>.</p>
<pre><code>$ docker network connect newNet MyContainer
</code></pre><p>Running <code>inspect</code> on the container once again will show you that <code>MyContainer</code> is now connected to <strong>both</strong> the <code>bridge</code> interface with its <code>172.17.0.2</code> address, <strong>and</strong> the <code>newNet</code> interface on <code>172.18.0.2</code>. It’s now like a computer with two network interface cards physically connected to separate networks.</p>
<p>Don’t believe me? You can successfully <code>ping</code> both interfaces from the command line, so we can see they’re both active. All this was possible, by the way, despite the fact that the container was up and running all along. Don’t try that on a physical machine!</p>
<pre><code>$ ping <span class="hljs-number">172.17</span><span class="hljs-number">.0</span><span class="hljs-number">.2</span>
PING <span class="hljs-number">172.17</span><span class="hljs-number">.0</span><span class="hljs-number">.2</span> (<span class="hljs-number">172.17</span><span class="hljs-number">.0</span><span class="hljs-number">.2</span>) <span class="hljs-number">56</span>(<span class="hljs-number">84</span>) bytes <span class="hljs-keyword">of</span> data.
<span class="hljs-number">64</span> bytes <span class="hljs-keyword">from</span> <span class="hljs-number">172.17</span><span class="hljs-number">.0</span><span class="hljs-number">.2</span>: icmp_seq=<span class="hljs-number">1</span> ttl=<span class="hljs-number">64</span> time=<span class="hljs-number">0.103</span> ms
<span class="hljs-number">64</span> bytes <span class="hljs-keyword">from</span> <span class="hljs-number">172.17</span><span class="hljs-number">.0</span><span class="hljs-number">.2</span>: icmp_seq=<span class="hljs-number">2</span> ttl=<span class="hljs-number">64</span> time=<span class="hljs-number">0.070</span> ms
^C
 — — <span class="hljs-number">172.17</span><span class="hljs-number">.0</span><span class="hljs-number">.2</span> ping statistics — -
<span class="hljs-number">2</span> packets transmitted, <span class="hljs-number">2</span> received, <span class="hljs-number">0</span>% packet loss, time <span class="hljs-number">999</span>ms
rtt min/avg/max/mdev = <span class="hljs-number">0.070</span>/<span class="hljs-number">0.086</span>/<span class="hljs-number">0.103</span>/<span class="hljs-number">0.018</span> ms
$ ping <span class="hljs-number">172.18</span><span class="hljs-number">.0</span><span class="hljs-number">.2</span>
PING <span class="hljs-number">172.18</span><span class="hljs-number">.0</span><span class="hljs-number">.2</span> (<span class="hljs-number">172.18</span><span class="hljs-number">.0</span><span class="hljs-number">.2</span>) <span class="hljs-number">56</span>(<span class="hljs-number">84</span>) bytes <span class="hljs-keyword">of</span> data.
<span class="hljs-number">64</span> bytes <span class="hljs-keyword">from</span> <span class="hljs-number">172.18</span><span class="hljs-number">.0</span><span class="hljs-number">.2</span>: icmp_seq=<span class="hljs-number">1</span> ttl=<span class="hljs-number">64</span> time=<span class="hljs-number">0.079</span> ms
<span class="hljs-number">64</span> bytes <span class="hljs-keyword">from</span> <span class="hljs-number">172.18</span><span class="hljs-number">.0</span><span class="hljs-number">.2</span>: icmp_seq=<span class="hljs-number">2</span> ttl=<span class="hljs-number">64</span> time=<span class="hljs-number">0.062</span> ms
^C
 — — <span class="hljs-number">172.18</span><span class="hljs-number">.0</span><span class="hljs-number">.2</span> ping statistics — -
<span class="hljs-number">2</span> packets transmitted, <span class="hljs-number">2</span> received, <span class="hljs-number">0</span>% packet loss, time <span class="hljs-number">999</span>ms
rtt min/avg/max/mdev = <span class="hljs-number">0.062</span>/<span class="hljs-number">0.070</span>/<span class="hljs-number">0.079</span>/<span class="hljs-number">0.011</span> ms
</code></pre><h4 id="heading-working-with-dockerfiles">Working with Dockerfiles</h4>
<p>While containers can be defined and controlled from the command line, the process can be largely automated through scripts called <a target="_blank" href="https://docs.docker.com/engine/reference/builder/">Dockerfiles</a>. Running <code>Dockerfile</code> as part of a docker build operation will tell Docker to create a container using the configurations specified by the script.</p>
<p>In the <code>simple dockerfile</code> example displayed below, the <code>FROM</code> line tells the docker host to use Ubuntu version 16.04 as the base operating system. If there isn’t already an Ubuntu 16.04 image on the local system, Docker will download one.</p>
<pre><code># Simple Dockerfile
FROM ubuntu:<span class="hljs-number">16.04</span>
RUN apt-get update
RUN apt-get install -y apache2
RUN echo “Welcome to my web site” &gt; <span class="hljs-regexp">/var/</span>www/html/index.html
EXPOSE <span class="hljs-number">80</span>
</code></pre><p>Each of the <code>RUN</code> lines launches a command within the operating system whose results will be included in the container — even before it’s actually launched as a live virtual machine.</p>
<p>In this case, <code>apt-get update</code> updates the local repository indexes to permit software downloads, <code>apt-get install apache2</code> will download and install the Apache webserver package. The <code>-y</code> will automatically answer “yes” to any prompts included in the installation process.</p>
<p>The <code>echo</code> command will replace the contents of the <code>index.html</code> file with my customized <code>Welcome</code> text. <code>index.html</code> is, of course, the first file a browser will look for and then load when it visits a new site.</p>
<p>Finally, <code>EXPOSE 80</code> opens up port 80 on the container to allow HTTP traffic — necessary because this will be a web server. This will allow us to access the web server from the Docker host machine. It’ll be your responsibility to provide access to your host for any remote clients you might want to invite in.</p>
<p>If you’re up on the latest Ubuntu package management news, you’ll know that there’s been a shift away from <code>apt-get</code> to its new <code>apt</code> replacement. So why did I use <code>apt-get</code> in that <code>Dockerfile</code>? Because it’s still more reliable for use in scripted settings.</p>
<p>To actually create a container based on this Dockerfile, you <code>run docker build</code> with <code>-t</code> to create a name (or “tag”) for the container. I’ll go with <code>webserver</code>. You add a space and then a dot to tell Docker to read the file named <code>Dockerfile</code> found in this current directory. Docker will immediately get to work building a container on top of the Ubuntu image we pulled earlier, and running the <code>apt-get</code> and <code>echo</code> commands.</p>
<pre><code>$ docker build -t “webserver” .
Sending build context to Docker daemon <span class="hljs-number">2.048</span> kB
Step <span class="hljs-number">1</span>/<span class="hljs-number">5</span> : FROM ubuntu:<span class="hljs-number">16.04</span>
<span class="hljs-number">16.04</span>: Pulling <span class="hljs-keyword">from</span> library/ubuntu
<span class="hljs-attr">Digest</span>: sha256:e27e9d7f7f28d67aa9e2d7540bdc2b33254b452ee8e
<span class="hljs-number">60</span>f388875e5b7d9b2b696
<span class="hljs-attr">Status</span>: Downloaded newer image <span class="hljs-keyword">for</span> ubuntu:<span class="hljs-number">16.04</span>
 — -&gt; <span class="hljs-number">0458</span>a4468cbc
Step <span class="hljs-number">2</span>/<span class="hljs-number">5</span> : RUN apt-get update
 — -&gt; Running <span class="hljs-keyword">in</span> c25f5462e0f2
[…]
Processing triggers <span class="hljs-keyword">for</span> systemd (<span class="hljs-number">229</span>–<span class="hljs-number">4</span>ubuntu21) …
Processing triggers <span class="hljs-keyword">for</span> sgml-base (<span class="hljs-number">1.26</span>+nmu4ubuntu1) …
 — -&gt; <span class="hljs-number">3</span>d9f2f14150e
Removing intermediate container <span class="hljs-number">42</span>cd3a92d3ca
Step <span class="hljs-number">4</span>/<span class="hljs-number">5</span> : RUN echo “Welcome to my web site” &gt; 
<span class="hljs-regexp">/var/</span>www/html/index.html
 — -&gt; Running <span class="hljs-keyword">in</span> ddf45c195467
 — -&gt; a1d21f1ba1f6
Removing intermediate container ddf45c195467
Step <span class="hljs-number">5</span>/<span class="hljs-number">5</span> : EXPOSE <span class="hljs-number">80</span>
 — -&gt; Running <span class="hljs-keyword">in</span> af639e6b1c85
 — -&gt; <span class="hljs-number">7</span>a206b180a62
Removing intermediate container af639e6b1c85
Successfully built <span class="hljs-number">7</span>a206b180a62
</code></pre><p>If I run <code>docker images</code>, I’ll now see a version of my Ubuntu image with the name <code>webserver</code>.</p>
<pre><code>$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
webserver latest <span class="hljs-number">7</span>a206b180a62 <span class="hljs-number">3</span> minutes ago <span class="hljs-number">250</span> MB
ubuntu <span class="hljs-number">16.04</span> <span class="hljs-number">0458</span>a4468cbc <span class="hljs-number">12</span> days ago <span class="hljs-number">112</span> MB
hello-world latest f2a91732366c <span class="hljs-number">2</span> months ago <span class="hljs-number">1.85</span> kB
</code></pre><p>Now we’re ready to launch the container using <code>docker run</code>.</p>
<p>Structuring this command properly is a bit of a delicate process and there’s a lot that can go wrong. The <code>-d</code> argument tells Docker to run this container detached, meaning we won’t find ourselves on the container’s command line but it will be running in the background. <code>-p</code> tells Docker to forward any traffic coming <strong>on</strong> port <code>80</code> (the default HTTP port) through <strong>to</strong> port <code>80</code> on the container. This allows external access to the web server. I can’t say that I understand why, but the order here is critical: only add the <code>-p</code> argument <strong>after</strong> <code>-d</code>.  </p>
<p>Next, we tell Docker the name of the container we’d like to launch, <code>webserver</code> in our case. And after that, we tell Docker to run a single command once the container is running to get the Apache webserver up.</p>
<pre><code>$ docker run -d -p <span class="hljs-number">80</span>:<span class="hljs-number">80</span> webserver \ /usr/sbin/apache2ctl -D FOREGROUND
</code></pre><p>Perhaps you’re wondering why I didn’t use the more modern <code>Systemd</code> command <code>systemctl start apache</code>. Well I tried it, and discovered that, at this point at least, systemd is good and broken in Ubuntu Docker containers. Stay away if you know what’s good for you. <code>-D FOREGROUND</code> ensures that Apache — and the container as a whole — will remain running even once the launch has completed. Run it for yourself.</p>
<p>We’re given an ID for the new container, but nothing else. You can run <code>docker ps</code> and you should see our <code>webserver</code> among the list of all running containers. You should also be able to open webserver’s <code>index.html</code> page by pointing your browser to the container’s IP address.</p>
<p>What’s that? You <strong>don’t know</strong> your container’s IP address? Well, since the container will have been associated with the default <code>bridge</code> network, you can use <code>docker network inspect bridge</code> and, within the Containers section of the output, you should find what you’re after. In my case, that was <code>172.17.0.3</code>.</p>
<h4 id="heading-working-with-docker-hub-images">Working with Docker Hub images</h4>
<p>We’ve already enjoyed some of the benefits Docker Hub has to offer. The images we used to build the containers on the previous clips were all seamlessly downloaded from Docker Hub behind the scenes.</p>
<p>In fact, using something like <code>docker search apache2</code>, you can manually comb through the repository for publicly available images that come with Apache pre-installed. You can also browse through what’s available on the <a target="_blank" href="https://hub.docker.com/">Docker Hub</a> web site.</p>
<p>However, you should remember that not all of those images are reliable or even safe. You’ll want to look for results that have earned lots of review stars and, in particular, are designated as “official.” Running <code>docker search ubuntu</code> returns at least a few official images.</p>
<p>Find something that interests you? You can add it to your local collection using d<code>ocker pull</code>. Once the download is complete, you can view your images using <code>docker images</code>.</p>
<pre><code>$ docker pull ubuntu-upstart
</code></pre><p>While you’re on the Docker Hub site, take the time to create a free account. That’ll allow you to store and share your own images much the way you might use a tool like GitHub. This is probably the most popular use-case for Docker, as it allows team members working remotely — or lazy devs working in the same office — to get instant and reliable access to the exact environments being used at every stage of a project’s progress.</p>
<p>Those are the bare-bone basics, and it’s important to understand them clearly. But, because of the complexity involved in coordinating clusters of dozens or thousands of containers all at once, most serious container workloads won’t use those particular command line tools.</p>
<p>Instead, you’re most likely going to want a more robust and feature-rich framework. You can read about some of those tools — including Docker’s own Docker Swarm Mode, Docker Enterprise Edition, or Docker Cloud, and Kubernetes — in my article, “<a target="_blank" href="https://hackernoon.com/too-many-choices-how-to-pick-the-right-tool-to-manage-your-docker-clusters-b5b3061b84b7">Too Many Choices: how to pick the right tool to manage your Docker clusters</a>”.</p>
<p>_This article is largely based on <a target="_blank" href="http://pluralsight.pxf.io/c/1191769/424552/7490?subId1=solving&amp;u=https%3A%2F%2Fapp.pluralsight.com%2Fprofile%2Fauthor%2Fdavid-clinton">video courses I authored for Pluralsight</a>. I’ve also got loads of Docker, AWS, and Linux content available through my <a target="_blank" href="https://bootstrap-it.com/">website</a>, including links to my book, <a target="_blank" href="https://www.manning.com/books/linux-in-action?a_aid=bootstrap-it&amp;a_bid=4ca15fc9">Linux in Action</a>, and a hybrid course called <a target="_blank" href="https://www.manning.com/livevideo/linux-in-motion?a_aid=bootstrap-it&amp;a_bid=0c56986f&amp;chan=motion1">Linux in Motion</a> that’s made up of more than two hours of video and around 40% of the text of Linux in Action._</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
