<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Docker on </title>
    <link>https://albertogalvez.com/categories/docker/</link>
    <description>Recent content in Docker on </description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Sat, 19 Oct 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://albertogalvez.com/categories/docker/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Docker</title>
      <link>https://albertogalvez.com/posts/docker/docker-configuration/</link>
      <pubDate>Sat, 19 Oct 2024 00:00:00 +0000</pubDate>
      
      <guid>https://albertogalvez.com/posts/docker/docker-configuration/</guid>
      <description>Docker Configuration Overview</description>
      <content:encoded><![CDATA[<h2 id="overview">Overview</h2>
<p><img loading="lazy" src="/posts/docker/docker-configuration/assets/dk.jpg" type="" alt="Docker Image"  /></p>
<h2 id="networking">Networking</h2>
<p><img loading="lazy" src="/posts/docker/docker-configuration/assets/dk-net.jpg" type="" alt="Docker Networking"  /></p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Docker Images</title>
      <link>https://albertogalvez.com/posts/docker/docker-images/</link>
      <pubDate>Sat, 19 Oct 2024 00:00:00 +0000</pubDate>
      
      <guid>https://albertogalvez.com/posts/docker/docker-images/</guid>
      <description>Docker Images</description>
      <content:encoded><![CDATA[<h1 id="docker-images">Docker Images</h1>
<ul>
<li>
<p><strong>Base Layer</strong> : The initial FROM instruction grabs the base lunchbox model (e.g., Ubuntu OS). This layer rarely changes.</p>
</li>
<li>
<p><strong>Intermediate Layers</strong> : Each subsequent instruction (RUN, COPY, etc.) usually adds a new transparent tray on top. Installing tools? A layer with utensils. Installing dependencies? The layer with the pre-washed lettuce and specific dressing packet.</p>
</li>
<li>
<p><strong>Layer Caching</strong> : When you build again, Docker checks your recipe. If an instruction hasn&rsquo;t changed (you used the same lettuce), Docker reuses the cached layer from the last time! It only rebuilds starting from the first changed instruction. Changed only your app code (top layer)? The build reuses all the heavy base layers and finishes in seconds, not minutes. It&rsquo;s like the chef grabbing the pre-made salad base and just adding your new garnish. This makes development incredibly fast.</p>
</li>
</ul>
<p>An Image is just the blueprint (the frozen meal). To actually run your application (eat the lunch), you use <code>docker run &lt;your-image-name&gt;</code>. This command:</p>
<ol>
<li>
<p>Takes the read-only Image layers (the frozen blueprint).</p>
</li>
<li>
<p>Adds a thin, writable layer on top (like a napkin for crumbs or temporary notes during the meal).</p>
</li>
<li>
<p>Starts your application process inside this new structure, following the CMD instruction from your recipe.</p>
</li>
</ol>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span><span class="lnt">6
</span><span class="lnt">7
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">docker run --name<span class="o">=</span>base-container -ti ubuntu
</span></span><span class="line"><span class="cl">apt update <span class="o">&amp;&amp;</span> apt install -y nodejs
</span></span><span class="line"><span class="cl">node -e <span class="s1">&#39;console.log(&#34;Hello world!&#34;)&#39;</span>
</span></span><span class="line"><span class="cl">docker container commit -m <span class="s2">&#34;Add node&#34;</span> base-container node-base
</span></span><span class="line"><span class="cl">docker image <span class="nb">history</span> node-base
</span></span><span class="line"><span class="cl">docker run node-base node -e <span class="s2">&#34;console.log(&#39;Hello again&#39;)&#34;</span>
</span></span><span class="line"><span class="cl">docker rm -f base-container
</span></span></code></pre></td></tr></table>
</div>
</div><h2 id="build-an-app-image">Build an app image</h2>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span><span class="lnt">6
</span><span class="lnt">7
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">docker run --name<span class="o">=</span>app-container -ti node-base
</span></span><span class="line"><span class="cl"><span class="nb">echo</span> <span class="s1">&#39;console.log(&#34;Hello from an app&#34;)&#39;</span> &gt; app.js
</span></span><span class="line"><span class="cl">node app.js
</span></span><span class="line"><span class="cl">docker container commit -c <span class="s2">&#34;CMD node app.js&#34;</span> -m <span class="s2">&#34;Add app&#34;</span> app-container sample-app
</span></span><span class="line"><span class="cl">docker image <span class="nb">history</span> sample-app
</span></span><span class="line"><span class="cl">docker run sample-app
</span></span><span class="line"><span class="cl">docker rm -f app-container
</span></span></code></pre></td></tr></table>
</div>
</div>]]></content:encoded>
    </item>
    
  </channel>
</rss>
