<?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" version="2.0"><channel><title><![CDATA[Untitled Publication]]></title><description><![CDATA[Untitled Publication]]></description><link>https://blog.anaspace.dev</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Apr 2026 10:25:30 GMT</lastBuildDate><atom:link href="https://blog.anaspace.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Docker — A must know for Every Developer]]></title><description><![CDATA[For Beginners

Are you a developer who struggles with deploying applications in different environments? Docker can help!
Imagine you’re trying to bake a cake, but every time you use a different oven, the cake turns out differently because of the diff...]]></description><link>https://blog.anaspace.dev/docker-a-must-know-for-every-developer</link><guid isPermaLink="true">https://blog.anaspace.dev/docker-a-must-know-for-every-developer</guid><category><![CDATA[Docker]]></category><category><![CDATA[Devops]]></category><category><![CDATA[software development]]></category><category><![CDATA[Developer Tools]]></category><dc:creator><![CDATA[Mohammad Anas]]></dc:creator><pubDate>Thu, 18 Jul 2024 19:10:47 GMT</pubDate><content:encoded><![CDATA[<blockquote>
<p><em>For Beginners</em></p>
</blockquote>
<p>Are you a developer who struggles with deploying applications in different environments? Docker can help!</p>
<p>Imagine you’re trying to bake a cake, but every time you use a different oven, the cake turns out differently because of the different settings. One day it’s perfect, the next day it’s burnt, and another day it’s undercooked. This is similar to what developers experience when deploying applications in different environments. Docker is like having a magical oven that always bakes your cake perfectly, no matter where you are.</p>
<p><img src="https://cdn-images-1.medium.com/max/1600/1*ACh4yFP-3GEpweUbyMCWwQ.png" alt /></p>
<h4 id="heading-so-what-exactly-is-docker">So what exactly is Docker</h4>
<p>Docker is a platform that packages applications and their dependencies into a little containers, ensuring they run same every time they’re deployed. It packs all the stuff your app needs to work — like code, libraries, and settings — into one box. This way, your app works exactly the same everywhere, whether it’s on your computer, a friend’s computer, or a server far away.</p>
<h4 id="heading-getting-started-with-docker">Getting started with docker</h4>
<p>Go to the <a target="_blank" href="https://docs.docker.com/desktop/install/mac-install/">Docker</a> website and download Docker Desktop for your operating system. Follow the installation instructions for your OS.</p>
<p>Below, I’ve added links to the installation process for each OS. You can follow these or check out the official Docker website.</p>
<ol>
<li><p>Installation steps for <a target="_blank" href="https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04#step-1-installing-docker">ubuntu</a></p>
</li>
<li><p>Installation steps for <a target="_blank" href="https://www.almabetter.com/bytes/articles/how-to-install-docker-for-mac#%22System%20Requirements%20for%20Docker%20for%20Mac%22">mac</a></p>
</li>
<li><p>Installion steps for <a target="_blank" href="https://www.geeksforgeeks.org/how-to-install-docker-on-windows/?ref=ml_lbp">windows</a></p>
</li>
</ol>
<h4 id="heading-running-a-simple-application-with-docker-container">Running a simple Application with docker container</h4>
<ol>
<li><strong>Check if Docker is Installed Correctly</strong></li>
</ol>
<ul>
<li><p>Open your terminal.</p>
</li>
<li><p>Type the command:</p>
</li>
</ul>
<pre><code class="lang-bash">docker --version
</code></pre>
<ul>
<li>You should see the Docker version information displayed. This confirms that Docker is installed and ready to use.</li>
</ul>
<p>2. <strong>Pulling an Image</strong></p>
<ul>
<li><p>When you pull an image, you’re downloading a ready-made package (like a recipe) from Docker’s library (Docker Hub). This image contains everything you need to run a specific piece of software, in this case, MySQL.</p>
</li>
<li><p>Type the command:</p>
</li>
</ul>
<pre><code class="lang-bash">docker pull mysql
</code></pre>
<p><img src="https://cdn-images-1.medium.com/max/1600/1*QmSc2LQ7VBTINTLKjC_NLQ.png" alt /></p>
<p><strong>3. Running the container</strong></p>
<ul>
<li><p>When you run the container, Docker takes the MySQL image you pulled (downloaded) and starts it as an isolated environment on your computer. It’s like using the recipe you downloaded to bake a cake in a mini kitchen (container) that Docker sets up for you.</p>
</li>
<li><p>Run the command</p>
</li>
</ul>
<pre><code class="lang-bash">docker run - name mysql-container -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql
</code></pre>
<ul>
<li><p>Docker starts the container and runs MySQL inside it. The <code>--name</code> flag gives the container a name, <code>-e</code> sets an environment variable for the MySQL root password, and <code>-d</code> runs the container in detached mode (in the background).</p>
</li>
<li><p>If you want to see the logs, you can simply omit <code>-d</code> and it will show you the logs.</p>
</li>
</ul>
<p><strong>4. Checking all the running containers</strong></p>
<ul>
<li><p><strong>How to check the status of your container?</strong> You can check if your MySQL container is running and see its details using Docker commands.</p>
</li>
<li><p>Type the command:</p>
</li>
</ul>
<pre><code class="lang-bash">docker ps
</code></pre>
<ul>
<li>This command lists all running containers. You should see your <code>mysql-container</code> listed with its status and port information.</li>
</ul>
<p><strong>5. Entering the MySQL Console</strong></p>
<ul>
<li><p>You can access the MySQL console from within the container to interact with the MySQL database directly.</p>
</li>
<li><p>Type the command:</p>
</li>
</ul>
<pre><code class="lang-bash">docker <span class="hljs-built_in">exec</span> -it mysql-container mysql -uroot -p
</code></pre>
<ul>
<li><p>You’ll be prompted to enter the MySQL root password (which you set as <code>my-secret-pw</code>). After entering the password, you'll be in the MySQL console.</p>
</li>
<li><p>Try creating the database and a few tables.</p>
</li>
<li><p>You can use this database in your project with the hostname: localhost, port: 5432 and the provided username and password.</p>
</li>
</ul>
<p>This was your basic container setup. Additionally, let’s say there’s another application that requires a specific older version of MySQL. You can run the older version similarly to the above steps, but you need to pass the version in the Docker pull command, like so: <code>docker pull mysql:5.6.23</code> and while running the container instead of using just <code>mysql</code> , use <code>mysql:5.6.3</code></p>
<p><strong>6. Using Docker Compose</strong></p>
<ul>
<li><p><strong>What is Docker Compose?</strong> Docker Compose is a tool that helps you run multiple containers as a single application. It uses a YAML file to define and run multi-container Docker applications. It’s like having a detailed menu that coordinates several recipes to create a full meal.</p>
</li>
<li><p><strong>When and Why to Use Docker Compose:</strong></p>
</li>
<li><p><strong>When</strong>: Use Docker Compose when you need to run more than one container at the same time, and they need to work together.</p>
</li>
<li><p><strong>Why</strong>: It simplifies the process of managing multiple containers and their dependencies. For ex, if your app needs a web server and a database, Docker Compose makes it easy to start both containers and link them together.</p>
</li>
<li><p>Create a file named <code>docker-compose.yml</code> in your project directory.</p>
</li>
<li><p>Define your services (containers) in this file. For ex, to run PostgreSQL and two versions of MySQL:</p>
</li>
</ul>
<pre><code class="lang-yaml"><span class="hljs-attr">version:</span> <span class="hljs-string">'3'</span> 
<span class="hljs-attr">services:</span>   
  <span class="hljs-attr">postgres:</span>     
    <span class="hljs-attr">image:</span> <span class="hljs-string">postgres</span>     
    <span class="hljs-attr">environment:</span>       
      <span class="hljs-attr">POSTGRES_PASSWORD:</span> <span class="hljs-string">mysecretpassword</span>   
  <span class="hljs-attr">mysql1:</span>     
    <span class="hljs-attr">image:</span> <span class="hljs-string">mysql:5.7</span>     
      <span class="hljs-attr">environment:</span>       
        <span class="hljs-attr">MYSQL_ROOT_PASSWORD:</span> <span class="hljs-string">my-secret-pw</span>   
  <span class="hljs-attr">mysql2:</span>     
    <span class="hljs-attr">image:</span> <span class="hljs-string">mysql:8</span>     
      <span class="hljs-attr">environment:</span>       
        <span class="hljs-attr">MYSQL_ROOT_PASSWORD:</span> <span class="hljs-string">my-secret-pw</span>
</code></pre>
<ul>
<li>Start the services using Docker Compose:</li>
</ul>
<pre><code class="lang-bash">docker-compose up -d
</code></pre>
<ul>
<li><p>When you run the above command all the services start running in the background because of the <code>-d</code> argument.</p>
</li>
<li><p>Similarly, to stop the services, you can use the command:</p>
</li>
</ul>
<pre><code class="lang-bash">docker-compose down
</code></pre>
<p><strong>SUMMARY</strong></p>
<p><strong>Docker</strong> is like having well-organized toolboxes for your projects, ensuring everything you need is in one place and works consistently. <strong>Docker Compose</strong> is your master plan for using multiple toolboxes together, making complex setups simpler. Whether you’re working on one project or many, Docker and Docker Compose help everything fit together and run smoothly.</p>
]]></content:encoded></item></channel></rss>