<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Piyush Pandit</title>
    <description>The latest articles on DEV Community by Piyush Pandit (@piyush_pandit_author).</description>
    <link>https://dev.to/piyush_pandit_author</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4211527%2Fab134ebc-242e-4c08-b6ce-26301254c456.png</url>
      <title>DEV Community: Piyush Pandit</title>
      <link>https://dev.to/piyush_pandit_author</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/piyush_pandit_author"/>
    <language>en</language>
    <item>
      <title>Docker for Beginners: Build, Run, and Troubleshoot Your First Container</title>
      <dc:creator>Piyush Pandit</dc:creator>
      <pubDate>Tue, 27 Oct 2026 18:10:28 +0000</pubDate>
      <link>https://dev.to/piyush_pandit_author/docker-for-beginners-build-run-and-troubleshoot-your-first-container-1ki9</link>
      <guid>https://dev.to/piyush_pandit_author/docker-for-beginners-build-run-and-troubleshoot-your-first-container-1ki9</guid>
      <description>&lt;h1&gt;
  
  
  Docker for Beginners: Build, Run, and Troubleshoot Your First Container
&lt;/h1&gt;

&lt;p&gt;Docker is one of the most useful tools for developers and IT professionals who want to run applications in consistent, isolated environments.&lt;/p&gt;

&lt;p&gt;In this tutorial, we'll create a basic container, build our own Docker image, and explore a few essential troubleshooting commands.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Check Your Docker Installation
&lt;/h2&gt;

&lt;p&gt;First, confirm Docker is installed and available:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker &lt;span class="nt"&gt;--version&lt;/span&gt;
docker info
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the Docker daemon isn't running, &lt;code&gt;docker info&lt;/code&gt; may display a connection error.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Run Your First Container
&lt;/h2&gt;

&lt;p&gt;Start an Nginx web server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;--name&lt;/span&gt; my-nginx &lt;span class="nt"&gt;-p&lt;/span&gt; 8080:80 nginx:alpine
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What this command does:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;-d&lt;/code&gt; runs the container in the background.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--name&lt;/code&gt; assigns a readable name.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-p 8080:80&lt;/code&gt; maps your computer's port 8080 to port 80 inside the container.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;nginx:alpine&lt;/code&gt; specifies the image to use.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Open &lt;code&gt;http://localhost:8080&lt;/code&gt; in your browser. You should see the Nginx welcome page.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Check Running Containers
&lt;/h2&gt;

&lt;p&gt;To see active containers:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;To see both running and stopped containers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker ps &lt;span class="nt"&gt;-a&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Build Your Own Docker Image
&lt;/h2&gt;

&lt;p&gt;Create a directory containing these two files.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;index.html&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Hello from my Docker container!&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; nginx:alpine&lt;/span&gt;
&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; index.html /usr/share/nginx/html/index.html&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Build the image:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker build &lt;span class="nt"&gt;-t&lt;/span&gt; my-first-image &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;--name&lt;/span&gt; custom-nginx &lt;span class="nt"&gt;-p&lt;/span&gt; 8081:80 my-first-image
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Visit &lt;code&gt;http://localhost:8081&lt;/code&gt; to see your custom page.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Troubleshoot Common Docker Problems
&lt;/h2&gt;

&lt;p&gt;Inspect a container's logs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker logs custom-nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;View container details:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker inspect custom-nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check resource usage:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Common problems include port conflicts, missing files, incorrect image names, and container startup failures.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Clean Up
&lt;/h2&gt;

&lt;p&gt;Stop and remove the containers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker stop my-nginx custom-nginx
docker &lt;span class="nb"&gt;rm &lt;/span&gt;my-nginx custom-nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Docker becomes easier to understand when you experiment with real containers instead of relying only on theory.&lt;/p&gt;

&lt;p&gt;Start with simple applications, learn how images and containers work, and gradually explore networking, volumes, Docker Compose, and security.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;About the author:&lt;/strong&gt; I'm Piyush Pandit, author of &lt;em&gt;Docker and Containers for IT Professionals&lt;/em&gt;, a practical guide to building, running, securing, and troubleshooting containers with Docker and Compose.&lt;/p&gt;

&lt;p&gt;My Kindle book is available through Amazon, with a limited-time free promotion when active.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.amazon.com/dp/B0HPBLDXT2" rel="noopener noreferrer"&gt;View the book on Amazon&lt;/a&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>tutorial</category>
      <category>containers</category>
    </item>
  </channel>
</rss>
