<?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: Pankil Soni</title>
    <description>The latest articles on DEV Community by Pankil Soni (@pankilsoni).</description>
    <link>https://dev.to/pankilsoni</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2250899%2F1ae6fabb-62b3-4a1e-a28e-0cebfda31402.png</url>
      <title>DEV Community: Pankil Soni</title>
      <link>https://dev.to/pankilsoni</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pankilsoni"/>
    <language>en</language>
    <item>
      <title>Day 2 of My DevOps Journey: Dockerizing Applications and Multi-Container Setup 🚀</title>
      <dc:creator>Pankil Soni</dc:creator>
      <pubDate>Wed, 23 Oct 2024 13:18:32 +0000</pubDate>
      <link>https://dev.to/pankilsoni/day-2-of-my-devops-journey-dockerizing-applications-and-multi-container-setup-3o0a</link>
      <guid>https://dev.to/pankilsoni/day-2-of-my-devops-journey-dockerizing-applications-and-multi-container-setup-3o0a</guid>
      <description>&lt;p&gt;After getting comfortable with basic Docker concepts yesterday, I dove deep into creating custom Docker images, deploying to AWS, and setting up multi-container applications. Here's my learning journey from Day 2!&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Creating Custom Dockerfiles 📝
&lt;/h2&gt;

&lt;p&gt;I created two applications and containerized them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A Flask application&lt;/li&gt;
&lt;li&gt;An Express.js application&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's the process I followed:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Created the applications locally&lt;/li&gt;
&lt;li&gt;Wrote Dockerfiles for each&lt;/li&gt;
&lt;li&gt;Built custom images&lt;/li&gt;
&lt;li&gt;Pushed them to Docker Hub&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Key commands used:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Building an image with host network access&lt;/span&gt;
docker build &lt;span class="nt"&gt;--network&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;host &lt;span class="nt"&gt;-t&lt;/span&gt; pankil1812/first-flask-app:0.0.2 &lt;span class="nb"&gt;.&lt;/span&gt;

&lt;span class="c"&gt;# Running the containerized application&lt;/span&gt;
docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 3000:3000 &lt;span class="nt"&gt;--name&lt;/span&gt; first-flask-app pankil1812/first-flask-app:0.0.2

&lt;span class="c"&gt;# Checking container logs&lt;/span&gt;
docker logs first-flask-app

&lt;span class="c"&gt;# Cleaning up unused containers&lt;/span&gt;
docker container prune
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. AWS EC2 Deployment 🌩️
&lt;/h2&gt;

&lt;p&gt;Next, I moved to cloud deployment:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Created a free-tier EC2 instance on AWS&lt;/li&gt;
&lt;li&gt;Installed Docker on the EC2 instance&lt;/li&gt;
&lt;li&gt;Successfully deployed both applications&lt;/li&gt;
&lt;li&gt;Accessed them via the EC2 public IP&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  3. Multi-Container Setup: MongoDB and Mongo Express 🔄
&lt;/h2&gt;

&lt;p&gt;The real challenge came with setting up a multi-container application using MongoDB and Mongo Express.&lt;/p&gt;

&lt;p&gt;First, pulled the necessary images:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Then, created a network and ran 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;&lt;span class="c"&gt;# Create a network for container communication&lt;/span&gt;
docker create network mongo-network

&lt;span class="c"&gt;# Run MongoDB container&lt;/span&gt;
docker run &lt;span class="nt"&gt;--network&lt;/span&gt; mongo-network &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 27017:27017 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;MONGO_INITDB_ROOT_USERNAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;admin &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;MONGO_INITDB_ROOT_PASSWORD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;password &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--name&lt;/span&gt; mongo mongo:latest

&lt;span class="c"&gt;# Run Mongo Express container&lt;/span&gt;
docker run &lt;span class="nt"&gt;--network&lt;/span&gt; mongo-network &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;ME_CONFIG_MONGODB_ADMINUSERNAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;admin &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;ME_CONFIG_MONGODB_ADMINPASSWORD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;password &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;ME_CONFIG_MONGODB_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"mongodb://admin:password@mongo:27017/"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;ME_CONFIG_BASICAUTH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;--name&lt;/span&gt; my-mongoexpress &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-p&lt;/span&gt; 8081:8081 mongo-express:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But I faced a lot of issues while setting up these because of environment variables. 🤔 But then I tried the new approach of using ME_CONFIG_MONGODB_URL instead of ME_CONFIG_MONGODB_SERVER. 🚀&lt;/p&gt;

&lt;p&gt;But finally I Successfully accessed Mongo Express UI through the EC2 public IP on port 8081! 🎉&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Introduction to Docker Compose 📋
&lt;/h2&gt;

&lt;p&gt;Finally, I learned about Docker Compose and created two compose files:&lt;/p&gt;

&lt;h3&gt;
  
  
  Express App Compose File
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;3'&lt;/span&gt;
&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;first-express-app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;pankil1812/first-express-app:0.0.1&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;5000:5000"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  MongoDB and Mongo Express Compose File
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;3'&lt;/span&gt;
&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;mongo&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;mongo&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;27017:27017"&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;MONGO_INITDB_ROOT_USERNAME=admin&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;MONGO_INITDB_ROOT_PASSWORD=password&lt;/span&gt;
    &lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;mongo-network&lt;/span&gt;

  &lt;span class="na"&gt;my-mongoexpress&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;mongo-express&lt;/span&gt;
    &lt;span class="na"&gt;restart&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;always&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;8081:8081"&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;ME_CONFIG_MONGODB_ADMINUSERNAME=admin&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;ME_CONFIG_MONGODB_ADMINPASSWORD=password&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;ME_CONFIG_MONGODB_URL=mongodb://admin:password@mongo:27017/&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;ME_CONFIG_BASICAUTH=false&lt;/span&gt;
    &lt;span class="na"&gt;depends_on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;mongo&lt;/span&gt;
    &lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;mongo-network&lt;/span&gt;

&lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;mongo-network&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;driver&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;bridge&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To implement this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Stopped all previous containers&lt;/li&gt;
&lt;li&gt;Removed the old network&lt;/li&gt;
&lt;li&gt;Used &lt;code&gt;docker-compose -f filename up&lt;/code&gt; to start the services&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Key Learnings 🎯
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Building and pushing custom Docker images&lt;/li&gt;
&lt;li&gt;Cloud deployment with AWS EC2&lt;/li&gt;
&lt;li&gt;Network creation and container communication&lt;/li&gt;
&lt;li&gt;Environment variable configuration&lt;/li&gt;
&lt;li&gt;Docker Compose for multi-container orchestration&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What's Next? 🚀
&lt;/h2&gt;

&lt;p&gt;For Day 3, I'm planning to explore:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Docker volume management&lt;/li&gt;
&lt;li&gt;Container health checks&lt;/li&gt;
&lt;li&gt;Docker Compose for development environments&lt;/li&gt;
&lt;li&gt;Container orchestration concepts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;my github repo for the sources is : &lt;a href="https://github.com/pankil-soni/my-devops-journey" rel="noopener noreferrer"&gt;https://github.com/pankil-soni/my-devops-journey&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;the sources where I learned docker from are:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=rr9cI4u1_88" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=rr9cI4u1_88&lt;/a&gt;&lt;br&gt;
&lt;a href="https://docs.docker.com/" rel="noopener noreferrer"&gt;https://docs.docker.com/&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Docker #DevOps #AWS #MongoDB #DockerCompose
&lt;/h1&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>beginners</category>
      <category>learning</category>
    </item>
    <item>
      <title>Day 1 of My DevOps Journey: Getting Started with Docker 🐳</title>
      <dc:creator>Pankil Soni</dc:creator>
      <pubDate>Tue, 22 Oct 2024 11:36:24 +0000</pubDate>
      <link>https://dev.to/pankilsoni/day-1-of-my-devops-journey-getting-started-with-docker-4d7o</link>
      <guid>https://dev.to/pankilsoni/day-1-of-my-devops-journey-getting-started-with-docker-4d7o</guid>
      <description>&lt;p&gt;Today marks the beginning of my DevOps learning journey, and I kicked it off by diving into Docker. Here's what I learned and accomplished on my first day.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu9d9c4leiftx5ep45q2z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu9d9c4leiftx5ep45q2z.png" alt="Docker meme" width="422" height="585"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;no more it works on my machine 🚀&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding the Basics
&lt;/h2&gt;

&lt;p&gt;First, I grasped the fundamental concepts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Containers&lt;/strong&gt;: Lightweight, standalone packages that include everything needed to run a piece of software, ensuring consistency across different environments.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docker&lt;/strong&gt;: A platform that enables creating, deploying, and running applications using container technology.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docker Hub&lt;/strong&gt;: The official repository for Docker images, like GitHub but for container images.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Essential Docker Commands
&lt;/h2&gt;

&lt;p&gt;I learned several basic Docker commands that are crucial for container management:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# List all running containers&lt;/span&gt;
docker ps

&lt;span class="c"&gt;# List all Docker images on your system&lt;/span&gt;
docker image &lt;span class="nb"&gt;ls&lt;/span&gt;

&lt;span class="c"&gt;# Pull an image from Docker Hub&lt;/span&gt;
docker pull &lt;span class="o"&gt;[&lt;/span&gt;image-name]

&lt;span class="c"&gt;# Remove containers or images&lt;/span&gt;
docker remove &lt;span class="o"&gt;[&lt;/span&gt;container-id/name]

&lt;span class="c"&gt;# Run a container&lt;/span&gt;
docker run &lt;span class="o"&gt;[&lt;/span&gt;options] &lt;span class="o"&gt;[&lt;/span&gt;image-name]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Hands-on Practice: Running Nginx
&lt;/h2&gt;

&lt;p&gt;My first practical exercise was setting up an Nginx web server using Docker. Here's how I did 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;--name&lt;/span&gt; my-nginx &lt;span class="nt"&gt;-p&lt;/span&gt; 8080:80 &lt;span class="nt"&gt;-d&lt;/span&gt; nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's break down this command:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;--name my-nginx&lt;/code&gt;: Assigns a custom name to the container&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-p 8080:80&lt;/code&gt;: Maps port 8080 on my host to port 80 in the container&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-d&lt;/code&gt;: Runs the container in detached mode (background)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;nginx&lt;/code&gt;: The image to use&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Connecting to Docker Playground
&lt;/h2&gt;

&lt;p&gt;One interesting challenge I tackled was accessing Docker Playground from Windows using Git Bash via SSH. This gave me experience with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Remote container management&lt;/li&gt;
&lt;li&gt;Using SSH for Docker connections&lt;/li&gt;
&lt;li&gt;Working with Docker in a cloud environment&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Key Takeaways from Day 1
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Docker simplifies application deployment through containerization&lt;/li&gt;
&lt;li&gt;Basic Docker commands are intuitive and follow a logical pattern&lt;/li&gt;
&lt;li&gt;Port mapping is crucial for accessing containerized applications&lt;/li&gt;
&lt;li&gt;Docker Playground provides a great environment for learning&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What's Next?
&lt;/h2&gt;

&lt;p&gt;Tomorrow, I plan to explore:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create own docker image using as Dockerfile.&lt;/li&gt;
&lt;li&gt;Deploying own simple express app.&lt;/li&gt;
&lt;li&gt;Multi-container applications.&lt;/li&gt;
&lt;li&gt;Docker networking basics.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;the resource I used for learning docker is : &lt;a href="https://youtu.be/rr9cI4u1_88?si=s8ehmucFYWfjcci5" rel="noopener noreferrer"&gt;https://youtu.be/rr9cI4u1_88?si=s8ehmucFYWfjcci5&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Stay tuned for more updates on my DevOps journey! Feel free to share your thoughts and suggestions in the comments below.&lt;/p&gt;

&lt;h1&gt;
  
  
  Docker #DevOps #Learning #TechBlog
&lt;/h1&gt;

</description>
      <category>docker</category>
      <category>beginners</category>
      <category>devops</category>
      <category>learning</category>
    </item>
  </channel>
</rss>
