<?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[ docker image - 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[ docker image - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Sun, 26 Jul 2026 22:34:20 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/docker-image/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to Remove All Docker Images – A Docker Cleanup Guide ]]>
                </title>
                <description>
                    <![CDATA[ By Sebastian Sigl Containers are everywhere in today’s tech world. The most popular technology for container management is Docker. It makes using containers easy and helps you easily get applications up and running.  Unfortunately, this can take a lo... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-remove-all-docker-images-a-docker-cleanup-guide/</link>
                <guid isPermaLink="false">66d460fa38f2dc3808b790eb</guid>
                
                    <category>
                        <![CDATA[ Docker ]]>
                    </category>
                
                    <category>
                        <![CDATA[ docker image ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Mon, 14 Mar 2022 20:25:16 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/03/docker-cleanup-guide.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Sebastian Sigl</p>
<p>Containers are everywhere in today’s tech world. The most popular technology for container management is <a target="_blank" href="https://www.docker.com/">Docker</a>. It makes using containers easy and helps you easily get applications up and running. </p>
<p>Unfortunately, this can take a lot of disk space, and you will eventually end up with a full disk.</p>
<p>It doesn't matter if you use Docker on your device or server. This guide shows you how you analyze used disk space and clean up different Docker resources.</p>
<p>All you need is a running Docker daemon and a terminal.</p>
<h2 id="heading-how-to-analyze-how-much-space-docker-is-using">How to analyze how much space Docker is using</h2>
<p>You can look up how much space is used by running the following command:</p>
<pre><code class="lang-sh">$ docker system df

TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          61        16        21.1GB    15.25GB (72%)
Containers      69        0         12.26MB   12.26MB (100%)
Local Volumes   3         2         539.1MB   50.04MB (9%)
Build Cache     76        0         1.242GB   1.242GB
</code></pre>
<p>You can get more information by using the verbose option <code>-v</code>:</p>
<pre><code class="lang-sh">$ docker system df -v

REPOSITORY        TAG   IMAGE ID     CREATED       SIZE      SHARED 
teamatldocker/jira    e50b8390945c   4 weeks ago     842.3MB   0B       
vw                    ed9e125a8925   2 months ago    1.659GB   134.8MB 

Containers space usage:

CONTAINER ID   IMAGE                    COMMAND                   SIZE 
94e03a4a17d0   teamatldocker/jira       <span class="hljs-string">"/sbin/tini -- /usr/…"</span>    1.4MB 

Local Volumes space usage:

VOLUME NAME                     LINKS     SIZE
play-with-jira_postgresqldata   1         84.19MB   
play-with-jira_jiradata         1         404.8MB

Build cache usage: 1.242GB

CACHE ID       CACHE TYPE     SIZE      CREATED        LAST USED 
oxil5sdicb91   regular        135MB     2 months ago   2 months ago  
kxz13fmdbodg   regular        13B       2 months ago   2 months ago 
nysus21ej7pf   regular        0B        2 months ago   2 months ago
</code></pre>
<p>As you can see, you get information about:</p>
<ul>
<li>Images space usage,</li>
<li>Containers space usage,</li>
<li>Local Volumes space usage, and</li>
<li>Build cache usage.</li>
</ul>
<h2 id="heading-how-to-clean-up-everything-in-docker">How to Clean Up Everything in Docker</h2>
<p>You can clean up everything or clean up specific resources in Docker like images, container volumes, or the build cache.</p>
<p>To clean up as much as possible excluding components that are in use, run this command:</p>
<pre><code class="lang-sh">$ docker system prune -a
</code></pre>
<p><code>-a</code> includes unused and dangling containers. Not providing <code>-a</code> would only delete dangling images, which are untagged images that have no relationship to any other images.</p>
<p>If you want to clean up most Docker resources but still keep tagged images, you can execute this command:</p>
<pre><code class="lang-sh">$ docker system prune
</code></pre>
<p>This is all you need to free up disk space quickly. Additionally, you can clean up components separately.</p>
<p>Here are a few more useful commands:</p>
<h3 id="heading-clean-up-unused-and-dangling-images">Clean up unused and dangling images</h3>
<pre><code class="lang-sh">$ docker image prune
</code></pre>
<h3 id="heading-clean-up-dangling-images-only">Clean up dangling images only</h3>
<pre><code class="lang-sh">$ docker image prune -a
</code></pre>
<h3 id="heading-clean-up-stopped-containers">Clean up stopped containers</h3>
<pre><code class="lang-sh">$ docker container prune
</code></pre>
<h3 id="heading-clean-up-unused-volumes">Clean up unused volumes</h3>
<pre><code class="lang-sh">$ docker volume prune
</code></pre>
<h2 id="heading-how-to-continuously-manage-your-used-docker-space-efficiently">How to Continuously Manage Your Used Docker Space Efficiently</h2>
<p>You can run something on a daily basis or at startup. To skip the usual prompt, you need to add <code>-f</code> to the command you want to run automatically. </p>
<p>Keep in mind that this will cause you to download images much more often because you regularly remove Docker resources.</p>
<p>If you don’t have a disk space issue, then don’t worry. Just clean things up as soon as heavy Docker disk usage catches your attention.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Today, there are many ways of cleaning up Docker disk space using the <code>docker</code> command. You can even execute these commands automatically if you want to clean up Docker resources regularly.</p>
<p>I hope you enjoyed the article.</p>
<p>If you liked it and felt the need to give me a round of applause or just want to get in touch, <a target="_blank" href="https://twitter.com/sesigl">follow me on Twitter</a>.</p>
<p>I work at eBay Kleinanzeigen, one of the world’s biggest classified companies. By the way, <a target="_blank" href="https://jobs.ebayclassifiedsgroup.com/ebay-kleinanzeigen">we are hiring</a>!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Docker Remove Image: How to Delete Docker Images Explained with Examples ]]>
                </title>
                <description>
                    <![CDATA[ By Marcelo Costa We live in an era where storage is becoming cheaper everyday. We can just send everything to the cloud and pay almost nothing. So why would we need to worry about deleting Docker images? First of all, there are still some mission cri... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/docker-remove-image-how-to-delete-docker-images-explained-with-examples/</link>
                <guid isPermaLink="false">66d851bcbdc56847ac959f42</guid>
                
                    <category>
                        <![CDATA[ Docker best practices ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Docker ]]>
                    </category>
                
                    <category>
                        <![CDATA[ docker image ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Productivity ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Wed, 22 Jul 2020 21:45:00 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/07/DockerErase3.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Marcelo Costa</p>
<p>We live in an era where storage is becoming cheaper everyday. We can just send everything to the cloud and pay almost nothing.</p>
<p>So why would we need to worry about deleting Docker images?</p>
<p>First of all, there are still some mission critical workloads that can't be moved to the cloud, especially those in heavily regulated industries like law or healthcare.  </p>
<p>But to better answer that question, I would say that we as developers often find ourselves out of space on our local machines.</p>
<p> Let's do a quick analysis of this <a target="_blank" href="https://cloud.google.com/blog/products/gcp/google-bigquery-public-datasets-now-include-stack-overflow-q-a">StackOverflow public dataset</a> to explore that further:</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> tag,
       title,
       answer_count,
       favorite_count,
       score,
       view_count VIEWS
<span class="hljs-keyword">FROM</span>
  (<span class="hljs-keyword">SELECT</span> title,
          answer_count,
          favorite_count,
          view_count,
          score,
          <span class="hljs-keyword">SPLIT</span>(tags, <span class="hljs-string">'|'</span>) tags
   <span class="hljs-keyword">FROM</span> <span class="hljs-string">`bigquery-public-data.stackoverflow.posts_questions`</span> 
         posts_questions), <span class="hljs-keyword">UNNEST</span>(tags) tag
<span class="hljs-keyword">WHERE</span> tag = <span class="hljs-string">'docker'</span>
  <span class="hljs-keyword">AND</span> title <span class="hljs-keyword">LIKE</span> <span class="hljs-string">'%space left%'</span>
<span class="hljs-keyword">ORDER</span> <span class="hljs-keyword">BY</span> VIEWS <span class="hljs-keyword">DESC</span>
</code></pre>
<p><strong>Query Results:</strong></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/07/Screen-Shot-2020-07-21-at-2.11.43-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>So it does't happen just with me, right? Look at how many views we have on those StackOverflow posts. If you are wondering, the number is <strong>465687</strong> views for posts matching the search query.</p>
<p>Luckily for us, today we are going to see some <strong>easy-to-use</strong> examples on how to delete our dangling and unused docker images to help ourselves out. </p>
<h2 id="heading-what-are-dangling-and-unused-docker-images">What are dangling and unused Docker images?</h2>
<div>
<img src="https://www.freecodecamp.org/news/content/images/2020/07/hanging3.png" alt="drawing" width="600" height="400" loading="lazy">
</div>

<p>What is the difference between dangling and unused images, you might ask?</p>
<p>A dangling image means that you've created a new build of the image but haven't given it a new name. Think about those old, forgotten images that no one knows what to do with anymore – those are "dangling images". </p>
<p>They are left untagged and display <code>&lt;none&gt;</code> on their name when you run <code>docker images</code>.</p>
<p>On the other hand, an unused image means that it has not been assigned or is not being used in a container. </p>
<p>For example, when running <code>docker ps -a</code> – it will list all your currently running containers plus exited containers. Any images being used inside any of containers are shown as "used images", and any others are unused.</p>
<h2 id="heading-delete-docker-images">Delete Docker Images</h2>
<p>Now let's see some examples of how to delete Docker images.</p>
<h3 id="heading-our-case-study">Our case study</h3>
<div>
<img src="https://www.freecodecamp.org/news/content/images/2020/07/busyCat.png" alt="drawing" width="600" height="400" loading="lazy">
</div>

<p>The Busy Cat Corp is a fictional company that captures cat behavior data, and provides recommendations to cat owners on how to make their pets busier and happier.  </p>
<p>All their workloads are containerized, and they use the following database images:<br><a target="_blank" href="https://hub.docker.com/_/cassandra">cassandra</a>, <a target="_blank" href="https://hub.docker.com/_/postgres">postgres</a>, <a target="_blank" href="https://hub.docker.com/_/mysql">mysql</a> and <a target="_blank" href="https://hub.docker.com/_/mongo">mongo</a>.</p>
<p>Their developers are constantly running out of space on their machines, and they are top users of StackOverflow – aren't we all?  </p>
<p>So they asked us for some quick examples of how to delete some images and get their space back.</p>
<p>First let's take a look at the machine of one of their developers.</p>
<pre><code class="lang-bash">docker images
</code></pre>
<p><strong>Output</strong></p>
<pre><code class="lang-bash">REPOSITORY  TAG          IMAGE ID            CREATED              SIZE
&lt;none&gt;       &lt;none&gt;      9c872a6119cc        About a minute ago   384MB
mysql        latest      5ac22cccc3ae        43 hours ago         544MB
cassandra    3           9fab0c92a93d        4 days ago           384MB
adoptopenjdk 8-jre...    2bf0172ac69b        4 days ago           210MB
mongo        latest      6d11486a97a7        2 weeks ago          388MB
postgres     latest      b97bae343e06        6 weeks ago          313MB
</code></pre>
<p>That's cool, they have all the images from their workloads downloaded. But look at the disk space – it's more than <strong>2GB</strong>! Let's see what we can do for them.</p>
<h3 id="heading-delete-docker-dangling-images">Delete Docker dangling images</h3>
<p>We'll start by looking for dangling images.</p>
<pre><code>docker images -qf <span class="hljs-string">"dangling=true"</span>
</code></pre><p><strong>Output</strong></p>
<pre><code class="lang-bash">REPOSITORY  TAG          IMAGE ID            CREATED              SIZE
&lt;none&gt;       &lt;none&gt;      9c872a6119cc        About a minute ago   384MB
</code></pre>
<p>We have one, so we are going to clear it up.</p>
<p><strong>Delete the dangling image</strong></p>
<pre><code>docker rmi $(docker images -qf <span class="hljs-string">"dangling=true"</span>)
</code></pre><div>
<img src="https://www.freecodecamp.org/news/content/images/2020/06/flamenco-done.png" alt="drawing" width="600" height="400" loading="lazy">
</div>

<h3 id="heading-delete-docker-unused-images">Delete Docker unused images</h3>
<p>Next we are looking for unused images.</p>
<pre><code>docker ps -a
</code></pre><p><strong>Output</strong></p>
<pre><code class="lang-bash">CONTAINER ID  IMAGE   CREATED           NAMES
b6387b343b81  mysql   16 minutes ago    some-mysql
</code></pre>
<p>We only have one container running the  <code>mysql</code>  image, so all the other images are unused. </p>
<p>So that we don't have to do it manually, we can put together a script that shows all of the unused images to verify them.</p>
<pre><code class="lang-bash"><span class="hljs-comment"># Get all the images currently in use</span>
USED_IMAGES=($( \
    docker ps -a --format <span class="hljs-string">'{{.Image}}'</span> | \
    sort -u | \
    uniq | \
    awk -F <span class="hljs-string">':'</span> <span class="hljs-string">'$2{print $1":"$2}!$2{print $1":latest"}'</span> \
))

<span class="hljs-comment"># Get all the images currently available</span>
ALL_IMAGES=($( \
    docker images --format <span class="hljs-string">'{{.Repository}}:{{.Tag}}'</span> | \
    sort -u \
))

<span class="hljs-comment"># Print the unused images</span>
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-string">"<span class="hljs-variable">${ALL_IMAGES[@]}</span>"</span>; <span class="hljs-keyword">do</span>
    UNUSED=<span class="hljs-literal">true</span>
    <span class="hljs-keyword">for</span> j <span class="hljs-keyword">in</span> <span class="hljs-string">"<span class="hljs-variable">${USED_IMAGES[@]}</span>"</span>; <span class="hljs-keyword">do</span>
        <span class="hljs-keyword">if</span> [[ <span class="hljs-string">"<span class="hljs-variable">$i</span>"</span> == <span class="hljs-string">"<span class="hljs-variable">$j</span>"</span> ]]; <span class="hljs-keyword">then</span>
            UNUSED=<span class="hljs-literal">false</span>
        <span class="hljs-keyword">fi</span>
    <span class="hljs-keyword">done</span>
    <span class="hljs-keyword">if</span> [[ <span class="hljs-string">"<span class="hljs-variable">$UNUSED</span>"</span> == <span class="hljs-literal">true</span> ]]; <span class="hljs-keyword">then</span>
        <span class="hljs-built_in">echo</span> <span class="hljs-string">"<span class="hljs-variable">$i</span> is not being used."</span>
    <span class="hljs-keyword">fi</span>
<span class="hljs-keyword">done</span>
</code></pre>
<p><strong>Output</strong></p>
<pre><code class="lang-bash">adoptopenjdk:8-jre-hotspot-bionic is not being used.
cassandra:3 is not being used.
mongo:latest is not being used.
postgres:latest is not being used.
</code></pre>
<p>Then it deletes the unused images.</p>
<pre><code># Get all the images currently <span class="hljs-keyword">in</span> use
USED_IMAGES=($( \
    docker ps -a --format <span class="hljs-string">'{{.Image}}'</span> | \
    sort -u | \
    uniq | \
    awk -F <span class="hljs-string">':'</span> <span class="hljs-string">'$2{print $1":"$2}!$2{print $1":latest"}'</span> \
))

# Get all the images currently available
ALL_IMAGES=($( \
    docker images --format <span class="hljs-string">'{{.Repository}}:{{.Tag}}'</span> | \
    sort -u \
))

# Remove the unused images
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-string">"${ALL_IMAGES[@]}"</span>; <span class="hljs-keyword">do</span>
    UNUSED=<span class="hljs-literal">true</span>
    <span class="hljs-keyword">for</span> j <span class="hljs-keyword">in</span> <span class="hljs-string">"${USED_IMAGES[@]}"</span>; <span class="hljs-keyword">do</span>
        <span class="hljs-keyword">if</span> [[ <span class="hljs-string">"$i"</span> == <span class="hljs-string">"$j"</span> ]]; then
            UNUSED=<span class="hljs-literal">false</span>
        fi
    done
    <span class="hljs-keyword">if</span> [[ <span class="hljs-string">"$UNUSED"</span> == <span class="hljs-literal">true</span> ]]; then
        docker rmi <span class="hljs-string">"$i"</span>
    fi
done
</code></pre><p>After deleting both dangling and unused images we can look at what we have left.</p>
<pre><code class="lang-bash">docker images
</code></pre>
<p><strong>Output</strong></p>
<pre><code class="lang-bash">REPOSITORY  TAG          IMAGE ID            CREATED              SIZE
mysql        latest      5ac22cccc3ae        43 hours ago         544MB
</code></pre>
<p>So we only have the <code>mysql</code>  image remaining, that's great!</p>
<div>
<img src="https://www.freecodecamp.org/news/content/images/2020/06/flamenco-done.png" alt="drawing" width="600" height="400" loading="lazy">
</div>

<h3 id="heading-delete-all-obsolete-docker-images-with-prune">Delete all obsolete Docker images with prune</h3>
<p>Those commands sound great, but a second developer said they didn't care about the differences between dangling and unused images. </p>
<p>All they wanted was to clear obsolete images and get their disk space back.</p>
<blockquote>
<p>Personally this is what I usually do.</p>
</blockquote>
<p>So we can just use Docker's prune commands.</p>
<pre><code># First <span class="hljs-keyword">delete</span> all stopped containers
docker container prune

# Then <span class="hljs-keyword">delete</span> both dangling and unused images
docker image prune --all
</code></pre><p>This will delete both unused and dangling images. Or in other words images without at least one container associated with them. </p>
<p>Note: this is why we needed to first delete the stopped containers in the code above.</p>
<h2 id="heading-wrapping-up"><strong>Wrapping </strong>up<em>**</em></h2>
<p>In this article we saw how to delete Docker Images, and we used a fictional company to explain it with some easy-to-use examples.</p>
<p>It's important to point out that you shouldn't use Docker to keep a history of your old images. For a developer environment that's fine, and you can even automate the image clean up workload if you have to deal with a lot of them. </p>
<p>But for a production workload, you should be using a Container Registry solution to handle your Docker images. </p>
<p>There are many Container Registry solutions out there, like Google Cloud Platform with <a target="_blank" href="https://cloud.google.com/artifact-registry">Artifact Registry</a> and Docker Enterprise with <a target="_blank" href="https://docs.mirantis.com/docker-enterprise/v3.0/dockeree-products/dtr.html">Docker Trusted Registry</a>. And if you are in the open source world, you can just use <a target="_blank" href="https://hub.docker.com/">Docker Hub</a> :).  </p>
<p>Thanks for reading!</p>
<ul>
<li>Illustrations from <a target="_blank" href="https://icons8.com/">Icons8</a></li>
</ul>
<p>If you found this helpful, or wish to challenge or extend anything raised here, feel free to contact me on <a target="_blank" href="https://twitter.com/mesmacosta">Twitter</a> or <a target="_blank" href="https://www.linkedin.com/in/mesmacosta">Linkedin</a>. Let's connect!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Docker Exec - How to Run a Command Inside a Docker Image or Container ]]>
                </title>
                <description>
                    <![CDATA[ By Jillian Rowe I'm going to let you in on a DevOps secret here: The thing all DevOpsy people love to do is build a super fancy and complex system, then find a way to deal with it like a regular shell. Or connect to it with SSH and then ]]>
                </description>
                <link>https://www.freecodecamp.org/news/docker-exec-how-to-run-a-command-inside-a-docker-image-or-container/</link>
                <guid isPermaLink="false">66d45f65052ad259f07e4afe</guid>
                
                    <category>
                        <![CDATA[ Docker ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Docker Containers ]]>
                    </category>
                
                    <category>
                        <![CDATA[ docker image ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Sat, 04 Apr 2020 14:49:12 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/03/antoine-petitteville-hHntcuiLbOg-unsplash.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Jillian Rowe</p>
<p>I'm going to let you in on a DevOps secret here: The thing all DevOpsy people love to do is build a super fancy and complex system, then find a way to deal with it like a regular shell. Or connect to it with SSH and then treat it like a regular shell.</p>
<p>Docker is no different! You are running a computer inside some other computer. Maybe that computer is an EC2 instance or a laptop. You can even get really crazy and run a VM that is then running Docker.</p>
<p>Most of the time when I use Docker I am using it to package and distribute an application. Sometimes I'm using it for something cooler like a distributed computing project. But a lot of times I'm throwing a Dockerfile in a GitHub repo so that I don't have to install CLIs that I just know will eventually conflict on my laptop.</p>
<p>Long story short, you can tell Docker to run the command <code>bash</code>, which drops you into a shell:</p>
<pre><code class="lang-bash">docker run -it name-of-image bash
<span class="hljs-comment"># docker run -it continuumio/miniconda3:latest bash</span>
<span class="hljs-comment"># docker run -it node:latest bash</span>
</code></pre>
<p>But keep reading for more. ;-)</p>
<h2 id="heading-try-it-out">Try it out</h2>
<p>Google your favorite programming language's Docker up. For me this is Python, and specifically I like conda. Then run a few commands to make sure that you are in fact in that shell.</p>
<pre><code class="lang-bash"><span class="hljs-comment"># From Host</span>
<span class="hljs-built_in">echo</span> $(<span class="hljs-built_in">pwd</span>)
<span class="hljs-comment"># Drop into docker shell</span>
docker run -it continuumio/miniconda3:latest bash
<span class="hljs-comment"># Now you are in the docker shell!</span>
<span class="hljs-built_in">echo</span> $(<span class="hljs-built_in">pwd</span>)
<span class="hljs-built_in">echo</span> <span class="hljs-variable">$USER</span>
</code></pre>
<p>Cool, huh? This is perfect for debugging a container that absolutely should be working properly. It's also great for my most common "I don't want to install this to my computer" use case. </p>
<h2 id="heading-debug-a-docker-build-with-docker-run">Debug a Docker Build with Docker Run</h2>
<p>Treating your Docker image like a regular shell will come in handy when trying to debug Docker builds. </p>
<p>Let's say you have a Dockerfile for an image you are trying to build. Normally what happens is that when running <code>docker build -t my-image .</code> (-t is for tag) Docker will run through each of your RUN steps, and stop when it gets to a command that does not exit properly. </p>
<p>In a UNIX shell, the exit code 0 means that all is well with a command. So to illustrate this point I have made our Dockerfile have a RUN command that exits with 1. </p>
<pre><code class="lang-bash">FROM continuumio/miniconda3:latest

RUN apt-get update -y; \
    apt-get upgrade -y; \
    apt-get install -y \
    vim-tiny vim-athena build-essential

RUN  conda update conda \
    &amp;&amp; conda clean --all --yes

RUN <span class="hljs-built_in">exit</span> 1
</code></pre>
<pre><code class="lang-bash">docker build -t my-image .
</code></pre>
<p>This will get you an output that looks like: </p>
<pre><code class="lang-bash">(base) ➜  my-image docker build -t my-image .
Sending build context to Docker daemon  2.048kB
Step 1/4 : FROM continuumio/miniconda3:latest
 ---&gt; 406f2b43ea59
Step 2/4 : RUN apt-get update -y;     apt-get upgrade -y;     apt-get install -y     vim-tiny vim-athena build-essential
 ---&gt; Using cache
 ---&gt; 726af29a48a0
Step 3/4 : RUN  conda update conda     &amp;&amp; conda clean --all --yes
 ---&gt; Using cache
 ---&gt; 19478bb3ce67
Step 4/4 : RUN <span class="hljs-built_in">exit</span> 1
 ---&gt; Running <span class="hljs-keyword">in</span> 7c98aab6b52c
The <span class="hljs-built_in">command</span> <span class="hljs-string">'/bin/sh -c exit 1'</span> returned a non-zero code: 1
</code></pre>
<p>You can confirm that your Docker image wasn't built by running <code>docker images</code> and checking for <code>my-image</code>. It won't be there because it wasn't successfully built. </p>
<p>Now what we can do is to comment out that troublesome Dockerfile RUN command.</p>
<pre><code class="lang-bash">FROM continuumio/miniconda3:latest

RUN apt-get update -y; \
    apt-get upgrade -y; \
    apt-get install -y \
    vim-tiny vim-athena build-essential

RUN  conda update conda \
    &amp;&amp; conda clean --all --yes

<span class="hljs-comment">#RUN exit 1</span>
</code></pre>
<p>Then what you will see is:</p>
<pre><code class="lang-bash">Sending build context to Docker daemon  2.048kB
Step 1/3 : FROM continuumio/miniconda3:latest
 ---&gt; 406f2b43ea59
Step 2/3 : RUN apt-get update -y;     apt-get upgrade -y;     apt-get install -y     vim-tiny vim-athena build-essential
 ---&gt; Using cache
 ---&gt; 726af29a48a0
Step 3/3 : RUN  conda update conda     &amp;&amp; conda clean --all --yes
 ---&gt; Using cache
 ---&gt; 19478bb3ce67
Successfully built 19478bb3ce67
Successfully tagged my-image:latest
</code></pre>
<p>You can now drop into your Docker image and start interactively running commands!</p>
<pre><code class="lang-bash">docker run -it my-image bash
<span class="hljs-comment"># you can also run</span>
<span class="hljs-comment"># docker run -it my-image:latest bash</span>
</code></pre>
<p>From here, one by one, you can start debugging your RUN commands to see what went wrong. If you're not sure if a command exited properly or not, run <code>$?</code>:</p>
<pre><code># First run docker run -it my-image bash to get to the shell
# Print the string hello
echo <span class="hljs-string">"hello"</span>
# hello
echo $?
# <span class="hljs-number">0</span>

# Run a non existant command hello
$(hello)
# bash: hello: command not found
echo $?
# <span class="hljs-number">127</span>
</code></pre><p>You can keep running these steps, commenting out your Dockerfile, dropping into a shell, and figuring out problematic commands, until your Docker images builds perfectly.</p>
<h2 id="heading-wrap-up">Wrap Up</h2>
<p>Hopefully I have shown you that using a Docker image is no different from the terminal on your computer. Using Docker images is an awesome way to distribute applications. </p>
<p>Try to take your favorite CLI application or next GitHub project, and instead of creating an install script, package it up with Docker. ;-)</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Connect your Microsoft SQL Server Docker Container with Azure Data Studio ]]>
                </title>
                <description>
                    <![CDATA[ By Clark Jason Ngo This guide shows you how to use Docker to pull a MSSQL Server image and run it. Azure Data Studio is a cross-platform database tool that will be using to connect our Docker container with MSSQL and execute SQL statements.  At the e... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/cjn-how-to-connect-your-microsoft-sql-server-docker-container-with-azure-data-studio/</link>
                <guid isPermaLink="false">66d45e0cf855545810e93427</guid>
                
                    <category>
                        <![CDATA[ mssql ]]>
                    </category>
                
                    <category>
                        <![CDATA[ database ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Docker ]]>
                    </category>
                
                    <category>
                        <![CDATA[ docker image ]]>
                    </category>
                
                    <category>
                        <![CDATA[ SQL ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Sun, 29 Mar 2020 11:22:53 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/03/Screen-Shot-2020-03-29-at-3.52.47-AM.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Clark Jason Ngo</p>
<p>This guide shows you how to use Docker to pull a MSSQL Server image and run it. Azure Data Studio is a cross-platform database tool that will be using to connect our Docker container with MSSQL and execute SQL statements. </p>
<p>At the end, I will show you how to import a database to the Docker file system so that you can access it through Azure Data Studio.</p>
<p>Check out other related guides here:</p>
<ul>
<li><em><a target="_blank" href="https://www.freecodecamp.org/news/cjn-how-to-connect-your-aws-rds-microsoft-sql-server-using-azure-data-studio/">How to Connect your AWS RDS Microsoft SQL Server using Azure Data Studio</a></em></li>
<li><a target="_blank" href="https://www.freecodecamp.org/news/cjn-how-to-import-a-sample-database-to-your-aws-rds-microsoft-sql-server-using-s3/"><em>How to Import a Sample Database to your AWS RDS Microsoft SQL Server using S3</em></a></li>
</ul>
<p>We will be touching on the technologies shown below:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-238.png" alt="Image" width="600" height="400" loading="lazy"></p>
<ul>
<li>Database: Microsoft SQL Server</li>
<li>Container to pull mssql-server-demo: Docker</li>
<li>Installer for mssql-cli: Node.js (Run-time Environment) / Node Package Manager (NPM)</li>
<li>Database tool and GUI: Azure Data Studio</li>
</ul>
<h2 id="heading-building-our-environment-with-docker">Building our Environment with Docker</h2>
<h3 id="heading-installing-docker">Installing Docker</h3>
<p>Full guide for this portion <a target="_blank" href="https://database.guide/how-to-install-sql-server-on-a-mac/">here</a>: </p>
<ol>
<li>Download Docker CE (Community Edition) for Mac <a target="_blank" href="https://store.docker.com/editions/community/docker-ce-desktop-mac?tab=description">here</a>.</li>
<li>To install, double-click on the .dmg file and then drag the Docker application icon to your Application folder.</li>
</ol>
<h4 id="heading-what-is-docker">What is Docker?</h4>
<p>Docker is a platform that enables software to run in its own isolated environment. SQL Server (from 2017) can be run on Docker in its own isolated container. </p>
<p>Once Docker is installed, you simply download — or “pull” — the SQL Server on Linux Docker Image to your Mac, then run it as a Docker container. This container is an isolated environment that contains everything SQL Server needs to run.</p>
<h3 id="heading-launch-docker">Launch Docker</h3>
<p>Open your Docker application, it should be located in the Applications folder.</p>
<h3 id="heading-increase-the-memory">Increase the Memory</h3>
<p>By default, Docker will have 2GB of memory allocated to it. SQL Server needs at least 3.25GB. To be safe, increase it to 4GB if you can. Since this is just a playground, 2GB should be enough.</p>
<h3 id="heading-optional-in-case-you-want-to-increase-memory-size">Optional - in case you want to increase memory size:</h3>
<ol>
<li>Select Preferences from the little Docker icon in the top menu</li>
<li>Slide the memory slider up to at least 2GB</li>
<li>Click Apply &amp; Restart</li>
</ol>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-245.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><img alt="Image" width="600" height="400" loading="lazy"></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-246.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-download-sql-server">Download SQL Server</h3>
<p>Open a Terminal window and run the following command.</p>
<pre><code class="lang-terminal">sudo docker pull mcr.microsoft.com/mssql/server:2019-latest
</code></pre>
<p>This downloads the latest SQL Server 2019 for Linux Docker image to your computer.</p>
<p>You can also check for the <a target="_blank" href="https://hub.docker.com/_/microsoft-mssql-server">latest container version</a> on the Docker website if you wish.</p>
<h3 id="heading-launch-docker-image">Launch Docker Image</h3>
<p>Run the following command to launch an instance of the Docker image you just downloaded:</p>
<pre><code class="lang-terminal">docker run -d --name sql_server_demo -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=really
</code></pre>
<p>Example output:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-254.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-check-the-docker-container-optional">Check the Docker container (optional)</h3>
<p>You can type the following command to check that the Docker container is running.</p>
<pre><code class="lang-terminal">docker ps
</code></pre>
<p>If it’s up and running, it should return something like this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-247.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>If you accidentally closed your Docker App, open your terminal and type</p>
<pre><code class="lang-terminal">docker start sql_server_demo
</code></pre>
<h3 id="heading-install-the-nodejs-and-npm">Install the Node.js and NPM</h3>
<p>Check if you have Node.js and NPM. Run the following commands in your terminal.</p>
<pre><code class="lang-terminal">node -v
npm -v
</code></pre>
<p>If you get an output with a version number, skip the rest of this section.</p>
<p>Then visit the Node.js website by clicking the following link:</p>
<p><a target="_blank" href="https://nodejs.org/en/">https://nodejs.org/en/</a></p>
<p>Click the LTS version (the version number may be various) download button to download the Node.js package:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-249.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Next click and run the package after downloading. MacOS and Windows will have different installation process. Please follow the instruction to install the Node.js.</p>
<p>Then test again if Node.js and NPM were installed successfully by running the following commands in the terminal:</p>
<pre><code class="lang-terminal">node -v
npm -v
</code></pre>
<p>An output should look like this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-248.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>#### </p>
<h3 id="heading-install-sql-cli">Install sql-cli</h3>
<p>Run the following command to install the sql-cli command line tool. This tool allows you to run queries and other commands against your SQL Server instance.</p>
<pre><code class="lang-terminal">npm install -g sql-cli
</code></pre>
<p>If you get a permission error, use the <code>sudo</code> command:</p>
<pre><code class="lang-terminal">sudo npm install -g sql-cli
</code></pre>
<p>### </p>
<h2 id="heading-connect-to-mssql-server">Connect to MSSQL Server</h2>
<p>Connect to your SQL Server using the mssql command, followed by the username and password parameters. Syntax: -u  -p </p>
<pre><code class="lang-terminal">mssql -u sa -p reallyStrongPwd123
</code></pre>
<p>Your output should look like this if you successfully connected:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-250.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-run-a-quick-test">Run a Quick Test</h3>
<p>Run a quick test to check if you can connect to your SQL Server. Use the following SQL statement to check your SQL Server version:</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> @@<span class="hljs-keyword">VERSION</span>;
</code></pre>
<p>If it’s running, you should see something like this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-251.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h2 id="heading-download-an-sql-server-gui-azure-data-studio">Download an SQL Server GUI - Azure Data Studio</h2>
<p><a target="_blank" href="https://database.guide/what-is-azure-data-studio/">Azure Data Studio</a> (formerly SQL Operations Studio) is a free GUI management tool that you can use to manage SQL Server on your computer. You can use it to create and manage databases, write queries, backup and restore databases, and more.</p>
<p>Azure Data Studio is available on Windows, Mac and Linux.</p>
<h3 id="heading-install-azure-data-studio">Install Azure Data Studio</h3>
<p>To install Azure Data Studio onto your Mac:</p>
<ol>
<li>Visit the <a target="_blank" href="https://docs.microsoft.com/en-us/sql/azure-data-studio/download">Azure Data Studio download page</a>, and click the .zip file for macOS</li>
<li>Once the .zip file has finished downloading, double click it to expand its contents</li>
<li>Drag the .app file to the Applications folder (the file will probably be called <em>Azure Data Studio.app</em>)</li>
</ol>
<h3 id="heading-connect-to-sql-server">Connect to SQL Server</h3>
<p>Now that Azure Data Studio is installed, you can use it to connect to SQL Server.</p>
<ol>
<li>Launch Azure Data Studio. It is located in your Applications folder.</li>
<li>Enter the login credentials and other information for the SQL Server instance that you’d like to connect to:</li>
</ol>
<p>It should look similar to this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-259.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>It should look similar to this:</p>
<ul>
<li><strong>Server Name</strong>: localhost, [port number]<br><strong>Example</strong>: localhost, 1433</li>
<li><strong>Authentication Type</strong>: SQL Login</li>
<li><strong>User name</strong>: [your SQL Server username] or sa</li>
<li><strong>Password</strong>: [your SQL Server password] or reallyStrongPwd123</li>
<li><strong>Database Name</strong>: </li>
<li><strong>Server Group</strong>: </li>
</ul>
<p>If you use a port other than the default 1433, click Advanced and enter it in the Port field.</p>
<p>Alternatively, you can append it to your server name with a comma in between. For example, if you used port 1400, type in localhost,1400.</p>
<p>You can now go ahead and create databases, run scripts, and perform other SQL Server management tasks.</p>
<ol>
<li>Click <strong>New Query</strong></li>
</ol>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-253.png" alt="Image" width="600" height="400" loading="lazy"></p>
<ol start="2">
<li>Type <strong>SELECT @@VERSION</strong>, then Click <strong>Run Query</strong>.</li>
</ol>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-241.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>You should be able to see: <em>Microsoft SQL Server</em> in the Results.</p>
<h2 id="heading-importing-a-sample-database-to-your-sql-server-using-azure-data-studio">Importing a sample database to your SQL Server using Azure Data Studio</h2>
<h3 id="heading-download-the-sample-database-file-adventureworks">Download the sample database file AdventureWorks</h3>
<p>To get the OLTP downloads of AdventureWorks, go to this <a target="_blank" href="https://docs.microsoft.com/en-us/sql/samples/adventureworks-install-configure?view=sql-server-ver15">link</a> and choose any sample database. In my example, I choose <code>AdventureWorks2017.bak</code>. We will upload this to the S3 Bucket.</p>
<h3 id="heading-copying-the-file-to-your-docker">Copying the file to your docker</h3>
<p>Type the following command in the terminal following this syntax:</p>
<pre><code>docker cp &lt;location_of_file&gt; <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">container_id</span>&gt;</span>:/var/opt/mssql/data</span>
</code></pre><p>It should look like this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-255.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>If you forgot your container id, use the <code>docker ps</code> command.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-258.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-importing-the-sample-database-in-docker">Importing the sample database in Docker</h3>
<p>Go to Azure Data Studio, and click the <strong>localhost, 1443</strong>, then choose <strong>Restore</strong>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-265.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Then choose <strong>Backup file</strong> as the selection for <em>Restore from</em>. Next, click the blue button on the right of <em>Backup file path.</em></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-264.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Look for the sample database file. It should be located in </p>
<pre><code class="lang-terminal">/var/opt/mssql/data/AdventureWorks2017.bak
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-260.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Choose <strong>Restore</strong>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-263.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Check your localhost, 1443. It should generated a Database named AdventureWorks2017 and have contents such as Tables and Views. If not, right-click on localhost, 1443 and choose Refresh. You can also restart your Azure Data Studio application. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-262.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-testing-the-sample-database">Testing the sample database</h3>
<ol>
<li>Choose <strong>AdventureWorks2017</strong> from the dropdown menu.</li>
<li>Write a SQL query:</li>
</ol>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> * <span class="hljs-keyword">FROM</span> HumanResources.Department;
</code></pre>
<ol start="3">
<li>Click <strong>Run</strong> to run the query.</li>
</ol>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-266.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>You should have an output like this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-267.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Congratulations! ???</p>
<p>Resources:</p>
<ul>
<li><a target="_blank" href="https://database.guide/how-to-install-sql-server-on-a-mac/">How to Install SQL Server on a Mac</a></li>
</ul>
<p>Connect with me on LinkedIn <a target="_blank" href="https://www.linkedin.com/in/clarkngo/">here</a></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-240.png" alt="Image" width="600" height="400" loading="lazy"></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Cleaning up Docker ]]>
                </title>
                <description>
                    <![CDATA[ By Faizan Bashir With the passage of time running Docker in development, we tend to accumulate a lot of unused images. Sometimes for testing, research or just trying out fun new stuff. It's always cool to run new software in containers, lights up new... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/cleaning-up-docker/</link>
                <guid isPermaLink="false">66d45eede39d8b5612bc0d9d</guid>
                
                    <category>
                        <![CDATA[ command line ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Docker ]]>
                    </category>
                
                    <category>
                        <![CDATA[ docker image ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Tutorial ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Fri, 05 Jul 2019 17:31:37 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2019/07/1_C6BkVKRpoVK_Pq1TLqlSkQ-3.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Faizan Bashir</p>
<p>With the passage of time running Docker in development, we tend to accumulate a lot of unused images. Sometimes for testing, research or just trying out fun new stuff. It's always cool to run new software in containers, lights up new possibilities for those of us interested in constantly learning new technologies. Downside is a lot of precious SSD memory occupied with rarely used or unused images, the worse thing is we hardly notice. But the guys at Docker Inc. have done a great task by keeping a track of all things Docker.</p>
<p>Say hello to the <code>system</code> command, part of the docker management commands and simply awesomeness. The <code>system</code> command provides info from disk usage to system-wide information, ain’t that cool.</p>
<h3 id="heading-disk-usage-using-df-command"><strong>Disk usage using</strong> <code>**df**</code> <strong>command:</strong></h3>
<pre><code>$ docker system df
</code></pre><p>Returns something like this,</p>
<pre><code>TYPE              TOTAL     ACTIVE     SIZE         RECLAIMABLE
Images            <span class="hljs-number">35</span>        <span class="hljs-number">6</span>          <span class="hljs-number">8.332</span>GB      <span class="hljs-number">7.364</span>GB (<span class="hljs-number">88</span>%)
Containers        <span class="hljs-number">12</span>        <span class="hljs-number">12</span>         <span class="hljs-number">417.6</span>MB      <span class="hljs-number">0</span>B (<span class="hljs-number">0</span>%)
Local Volumes     <span class="hljs-number">67</span>        <span class="hljs-number">2</span>          <span class="hljs-number">2.828</span>GB      <span class="hljs-number">2.828</span>GB (<span class="hljs-number">100</span>%)
Build Cache                            <span class="hljs-number">0</span>B           <span class="hljs-number">0</span>B
</code></pre><p>Notice the <code>Reclaimable</code> this is the size you can recover, it is calculated by subtracting the size of active images from the size of total images.</p>
<hr>
<p><strong>Real time events using</strong> <code>**events**</code> <strong>command:</strong></p>
<pre><code>$ docker system events
</code></pre><p>Returns the list of real time events from the server, based on Docker object types.</p>
<p>Formatting output</p>
<pre><code>--format <span class="hljs-string">'Type={{.Type}}  Status={{.Status}}  ID={{.ID}}'</span>
</code></pre><p>or simply format the output as JSON</p>
<pre><code>$ docker system events --format <span class="hljs-string">'{{json .}}'</span>
</code></pre><hr>
<p><strong>System-wide info using</strong> <code>**info**</code> <strong>command:</strong></p>
<p>Another cool command to get all the system related information is the <code>info</code> command. You will be amazed to see the amount of info you can get.</p>
<pre><code>$ docker system info
</code></pre><hr>
<p><strong>Remove unused data using</strong> <code>**prune**</code> <strong>command:</strong></p>
<p>Now that we have all the info we need, its cleanup time, but beware against using this command half asleep.</p>
<pre><code>$ docker system prune
WARNING! This will remove:        
    - all stopped containers        
        - all networks not used by at least one container        
        - all dangling images        
        - all build cache
Are you sure you want to <span class="hljs-keyword">continue</span>? [y/N]
</code></pre><p>Further we can remove exactly what we want, using any of the following commands, feast you eyes ladies and gents.</p>
<pre><code>$ docker system prune -a --volumes
$ docker image prune
$ docker container prune
$ docker volume prune
$ docker network prune
</code></pre><p>All of the above commands will prompt for confirmation, so wash your face with cold water or take a shot of Espresso before issuing any of these ;).</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Let me guide you through your first date with Docker ]]>
                </title>
                <description>
                    <![CDATA[ By Chandrabhan Singh Install Docker, create your first container, and more You may have seen Docker somewhere on the internet and you may feel curious about it. Now you want to take it to the next level. How about going on a date with Docker? No — I ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/let-me-guide-you-through-your-first-date-with-docker-f03f35567d95/</link>
                <guid isPermaLink="false">66d45dd7c7632f8bfbf1e3e9</guid>
                
                    <category>
                        <![CDATA[ containers ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Docker ]]>
                    </category>
                
                    <category>
                        <![CDATA[ docker image ]]>
                    </category>
                
                    <category>
                        <![CDATA[ technology ]]>
                    </category>
                
                    <category>
                        <![CDATA[ visualization ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Thu, 31 May 2018 19:38:50 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*aKHmBi9PuIUTpp0buimRsA.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Chandrabhan Singh</p>
<h4 id="heading-install-docker-create-your-first-container-and-more">Install Docker, create your first container, and more</h4>
<p>You may have seen Docker somewhere on the internet and you may feel curious about it. Now you want to take it to the next level. How about going on a date with Docker? No — I am not kidding!</p>
<p>But, how do you plan a perfect first date? What should you do? Where to find the right resources? What prerequisites might you need?</p>
<p>The questions are endless. Follow these first-date guidelines, and you’ll be well on your way to landing a second.</p>
<h3 id="heading-planning-your-date">Planning your date</h3>
<p>Getting to know your date before you start planning is crucial to crafting a memorable first experience. It will likely boost your confidence during the meeting, as well.</p>
<p>It’s never too late to say Hi. <a target="_blank" href="https://medium.com/@chandrabhan_/docker-what-i-learned-bc3587e17f17">Here</a> is a short introduction to my first time meeting Docker if you’re interested.</p>
<p>Okay! So the road map we will follow today looks something like this:</p>
<ol>
<li>Setting up the Venue</li>
<li>The Pickup</li>
<li>The Conversation</li>
</ol>
<h3 id="heading-prelude"><strong>Prelude</strong></h3>
<p>The place where we will set up our date is the Docker engine.</p>
<p>Docker engine is no different from any other engine. It is a combination of various components working together.</p>
<p>We will see a few of these components later in this article. But for now, let’s decorate our machine with Docker. The installation process depends upon your operating system.</p>
<p>The key for uninterrupted execution is always to refer to an official website. Docker has this fantastic <a target="_blank" href="https://docs.docker.com/install/">guide</a>, where you can find out more about installation.</p>
<p>Docker comes in two flavors: Docker Community Edition (CE) and Docker Enterprise Edition (E.E.). For our demonstration purposes, we must stick to the community edition. The Enterprise Edition is paid. And besides, making an expensive reservation for your first date is not the best idea ?</p>
<h3 id="heading-the-venue">The Venue</h3>
<p>The core mantra for any propitious date is to choose the right meeting place. Meeting Docker is no different. First, we should decide on the platform. Cloud? Mac? Linux? Or Windows? Once we know our environment, we can choose the simplest way to set up the meeting place.</p>
<h4 id="heading-windows">Windows</h4>
<p>If your choice is Windows, the process for setup is quite simple. Remember our favorite process: Next, Next, Next, and Finish.</p>
<p>Jump to the download <a target="_blank" href="https://store.docker.com/editions/community/docker-ce-desktop-windows">page</a> and choose the “Edge channel.” Edge has experimental features and fits best for our learning purposes.</p>
<p><strong>Note!</strong> Docker for Windows needs the “Hyper-V” feature, but there is nothing to worry about — Docker will turn it on for you. However, it means that you can’t use Virtual Box.</p>
<h4 id="heading-linux">Linux</h4>
<p>When I first started experimenting on a Linux box, I thought it was going to be a nightmare. But to my relief, setting up Docker on a Linux distribution turned out to be simple. Again, there are many ways to install Docker on a Linux distribution.</p>
<p>My favorite is: “Install using the convenience script.” We grab a long shell script from the internet and then pipe it to a shell terminal.</p>
<p>How? Like this:</p>
<pre><code>sudo wget -qO- https:<span class="hljs-comment">//get.docker.com |sh</span>
</code></pre><p><strong>Done</strong>! Yeah, you have Docker on your machine up and running.</p>
<p>Now that the venue is all set, we are ready to proceed. But first, let’s make some inquiries to make sure everything is working fine here. The same as you might inquire with a restaurant before booking a table ?.</p>
<p>Let’s execute the below command in the terminal:</p>
<pre><code>docker version
</code></pre><p>You should see the installation details. It gives you information about the <strong>Client</strong> and <strong>Server</strong> version, the <strong>Go-lang</strong> version, and so on and so forth.</p>
<p>If the output of your command is somehow like the one below, the sun is shining, and the world is beautiful. <strong>Next</strong>: time to get ready for the “Pickup.”</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/n435DcbT4csc32tM5JOtrQrRDrvGHZZqhUx2" alt="Image" width="738" height="493" loading="lazy">
<em>Command output</em></p>
<h3 id="heading-the-pickup"><strong>The Pickup</strong></h3>
<p>As you may already be aware, Docker uses <strong>Images</strong> to create containers. These images are large binary immutable files.</p>
<p>An image contains application binaries and their dependencies. It may also contain other components such as a web server or even an OS.</p>
<p>We will need such images to create a container and run an application inside it.</p>
<p>So, where do these images live? Simple question, simple answer: on a Host. This host can be your machine or a registry somewhere on the internet. <a target="_blank" href="http://docker.io/">Docker</a> has its registry called Docker-Hub.</p>
<h4 id="heading-to-avoid-wandering-you-should-know-the-right-pickup-location-for-your-date">To avoid wandering, you should know the right pickup location for your date.</h4>
<p>To make your first date smoother, I found the exact location of an image that I can share with you. Excited enough? Here you go!</p>
<pre><code>docker pull chandrabhan/dotnetconsole
</code></pre><p>Let’s confirm that we are at the right location. ?</p>
<pre><code>docker image ls
</code></pre><p><img src="https://cdn-media-1.freecodecamp.org/images/ESkhGnOlmgnvsNWlJwQi45OdWHMWXM0m2wPD" alt="Image" width="800" height="327" loading="lazy">
<em>command output</em></p>
<p>Here you can see various properties of the images on your machine. Cool, it looks like things are going good so far.</p>
<p>Before moving further, let’s break down the previous two commands and understand what’s going on here.</p>
<p>With <code>Docker pull</code>, we asked Docker Daemon to pull an image for us. The Daemon could not find the image in the local registry, so it went ahead and pulled a remote copy from Docker-Hub.</p>
<p>Through <code>docker image ls</code> we saw all available images and their properties.</p>
<p>I must admit, I am getting excited. We’ve done a great job so far. Next, let the interaction begin.</p>
<h3 id="heading-the-conversation">The Conversation</h3>
<h4 id="heading-start-the-conversation-and-things-will-turn-out-in-your-favor">Start the conversation, and things will turn out in your favor.</h4>
<p>So again, to make it smoother for you, I want to offer you a few icebreakers.</p>
<p>We will create some containers for .Net Core framework applications. The first one will be a simple console application. The other will be a bit more colorful — a web application.</p>
<pre><code>docker run chandrabhan/dotnetconsole
</code></pre><p><img src="https://cdn-media-1.freecodecamp.org/images/CX7U8rR4b1bPzulYe15hEShC5IFrYEAy1Y3k" alt="Image" width="800" height="322" loading="lazy">
<em>command output</em></p>
<p>Magnificent! Did you see what happened there? This stuff is amazing. A .Net core application is running inside a container. Docker went ahead and created a container and executed the application inside it. And as soon as the console application ends, the container exists!</p>
<p>Let’s see how many containers we have in our machine:</p>
<pre><code>docker container ls -a
</code></pre><p><img src="https://cdn-media-1.freecodecamp.org/images/tuXcPX2nL8L7UQ5huyqHwvKip6Lm8-qFu0Cv" alt="Image" width="800" height="307" loading="lazy">
<em>command output</em></p>
<p>What you see here is the list of containers on your machine. You can identify a container by its <code>**ID**</code>. The output tells us when the container was <code>**CREATED**</code> and what it’s current <code>**STATUS**</code> is. The container we created is in <code>**Exited**</code> status. Remember? Our application is exited! So is the container.</p>
<p>It looks like the conversation is progressing well, so let’s keep going.</p>
<pre><code>docker run -it --rm -p <span class="hljs-number">5000</span>:<span class="hljs-number">80</span> --name app chandrabhan/aspdotnet
</code></pre><p>Go to your favorite browser and browse <code>http://localhost:5000</code>. You should see more amazing stuff.</p>
<p>An ASP.Net core web app is running inside a container:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/bE3jqk9-iKAtDEdeHgqqiNYhCe2SXvAEOZ1c" alt="Image" width="800" height="395" loading="lazy">
<em>containerized - sample ASP.Net application</em></p>
<p>Before moving further, let’s see the anatomy of the above command.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/inCu2ZgNwFRlxd4z9BN4hM7344sBOG53BB4I" alt="Image" width="800" height="361" loading="lazy">
<em>command anatomy</em></p>
<p>Did you notice? This time we did not pull the image, but we were still able to create a container out of it. When you execute <code>docker run</code>, Docker daemon tries to find a local copy of the image. If it cannot, it goes ahead and tries to find it in the default registry (Docker-Hub in this case).</p>
<p>I believe our planning was excellent and so was the execution. Let’s rewind what we did and review how we planned an auspicious date with Docker ?.</p>
<h3 id="heading-rewinding"><strong>Rewinding</strong></h3>
<ol>
<li>First, we installed Docker. We saw how the installation process varies depending on the operating system.</li>
<li>Then we went ahead and pulled an image from the Docker-Hub registry, a simple .Net Core console app.</li>
<li>Once we had this image on our machine, we used Docker to create a container out of this image.</li>
<li>We also saw how to pull an image and run a container through a single command.</li>
</ol>
<p>Here is an illustration that may help you understand a high-level picture.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/PuQLeHlccMgOtNb5VFtvC0uuYnEjuaVb9J22" alt="Image" width="800" height="298" loading="lazy">
<em>illustration: Docker client and daemon</em></p>
<h3 id="heading-follow-up">Follow up</h3>
<h4 id="heading-out-of-sight-out-of-mind">Out of sight out of mind</h4>
<p>Following up is as important as any other stage during the date. Now I should leave you with your date, and would like to hear how it went. Below are a few links that may be useful:</p>
<ul>
<li><a target="_blank" href="https://github.com/SinghChandrabhan/DockerSamples">Github</a></li>
<li><a target="_blank" href="https://hub.docker.com/u/chandrabhan">Docker hub</a></li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
