<?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: Atiye</title>
    <description>The latest articles on DEV Community by Atiye (@dadbam).</description>
    <link>https://dev.to/dadbam</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%2F3180689%2F9d9121b2-07e8-44fc-a3e7-67549dff9af7.png</url>
      <title>DEV Community: Atiye</title>
      <link>https://dev.to/dadbam</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dadbam"/>
    <language>en</language>
    <item>
      <title>🐳 Docker Made Simple — From Cake to Code</title>
      <dc:creator>Atiye</dc:creator>
      <pubDate>Fri, 23 May 2025 12:38:42 +0000</pubDate>
      <link>https://dev.to/dadbam/docker-made-simple-from-cake-to-code-4d5h</link>
      <guid>https://dev.to/dadbam/docker-made-simple-from-cake-to-code-4d5h</guid>
      <description>&lt;p&gt;**“But it works on my machine!”&lt;/p&gt;

&lt;p&gt;If you’re a developer, you’ve probably heard (or said!) this phrase.&lt;br&gt;
It’s that frustrating moment when your app runs perfectly on your laptop but throws a tantrum when deployed somewhere else.&lt;/p&gt;

&lt;p&gt;Why?&lt;br&gt;
Because every system is a little different — different OS, different package versions, different configs.&lt;/p&gt;

&lt;p&gt;That’s where Docker comes in to save the day.&lt;/p&gt;

&lt;p&gt;🔍 What is Docker in Plain English?&lt;/p&gt;

&lt;p&gt;Think of Docker like a sealed food container — but for your app.&lt;br&gt;
It packages everything your app needs to run:&lt;/p&gt;

&lt;p&gt;🖥️ Your code&lt;br&gt;
📚 Dependencies and libraries&lt;br&gt;
⚙️ Environment variables&lt;br&gt;
🛠️ Configuration files&lt;br&gt;
🖼️ A lightweight slice of the operating system&lt;/p&gt;

&lt;p&gt;This bundle, called a container, is a self-contained unit that runs your app identically on:&lt;br&gt;
Your teammate’s MacBook&lt;br&gt;
A Linux test server&lt;br&gt;
A cloud provider like AWS or Azure&lt;br&gt;
Even a Raspberry Pi in your garage!&lt;br&gt;
No more “works on my machine” excuses. Docker ensures consistency, every time.&lt;/p&gt;

&lt;p&gt;..........................................................................&lt;/p&gt;

&lt;p&gt;🍰 The Cake Analogy — Understanding Docker with Dessert&lt;/p&gt;

&lt;p&gt;Let’s say you want to bake a cake. You write down a recipe:&lt;/p&gt;

&lt;p&gt;3 eggs, 2 cups flour, 1/2 cup sugar… bake at 180°C.&lt;/p&gt;

&lt;p&gt;Now let’s map this to Docker concepts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Concept       | Cake Analogy                                     | Technical Definition
------------- | ------------------------------------------------ | ---------------------------------------
Dockerfile    | The recipe                                       | Instructions to build an image
Image         | A prepped cake mold or frozen kit                | A snapshot of the app and its dependencies
Container     | A freshly baked cake from the mold               | A running instance of the image
Volume        | A separate drawer for storing chocolate          | Persistent storage shared with the container
Network       | A kitchen where cakes can talk to each other     | Communication layer between containers
Docker Compose| A master chef who runs multiple recipes together | A file to run multi-container apps easily

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🧁 Think of it this way:&lt;br&gt;
A Dockerfile is your recipe.&lt;br&gt;
You use it to bake an image — like a cake mold.&lt;br&gt;
From that mold, you can bake as many containers (actual cakes) as you want — even at the same time!&lt;/p&gt;



&lt;p&gt;💻 Real-World Example: Dockerizing a .NET Web API with SQL Server&lt;/p&gt;

&lt;p&gt;🎯 The Goal:&lt;/p&gt;

&lt;p&gt;You’ve built a simple ASP.NET Core Web API that connects to a SQL Server database.&lt;br&gt;
Now you want to run the whole system with Docker — cleanly and easily.&lt;/p&gt;

&lt;p&gt;🗂️ Project Structure:&lt;/p&gt;

&lt;p&gt;MyApp/&lt;/p&gt;

&lt;p&gt;├── MyApp.API/&lt;/p&gt;

&lt;p&gt;│ └── (your API source code)&lt;/p&gt;

&lt;p&gt;├── docker-compose.yml&lt;/p&gt;

&lt;p&gt;├── MyApp.API/&lt;/p&gt;

&lt;p&gt;│ └── Dockerfile&lt;/p&gt;

&lt;p&gt;📝 Dockerfile:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /app
COPY . ./
RUN dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/aspnet:7.0
WORKDIR /app
COPY --from=build /app/out .
ENTRYPOINT ["dotnet", "MyApp.API.dll"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🧬 docker-compose.yml:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: '3.4'

services:
  webapi:
    build:
      context: ./MyApp.API
    ports:
      - "5000:80"
    depends_on:
      - db
    environment:
      - ConnectionStrings__DefaultConnection=Server=db;Database=MyAppDb;User=sa;Password=Your_password123;

  db:
    image: mcr.microsoft.com/mssql/server:2022-latest
    environment:
      SA_PASSWORD: "Your_password123"
      ACCEPT_EULA: "Y"
    ports:
      - "1433:1433"
    volumes:
      - sqlvolume:/var/opt/mssql

volumes:
  sqlvolume:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🚀 Run the App:&lt;/p&gt;

&lt;p&gt;docker-compose up — build&lt;/p&gt;

&lt;p&gt;Now your app is live on &lt;a href="http://localhost:5000" rel="noopener noreferrer"&gt;http://localhost:5000&lt;/a&gt;&lt;br&gt;
And your SQL Server is running in a container, ready to go.&lt;/p&gt;

&lt;p&gt;💬 Final Thoughts&lt;/p&gt;

&lt;p&gt;Docker gives your app a spaceship — a sealed environment that can land anywhere and still function the same. 🚀&lt;br&gt;
Whether it’s your teammate’s laptop, a staging server, or the cloud — no more “but it works on my machine!”&lt;/p&gt;

&lt;p&gt;So if you’re a developer and haven’t tried Docker yet… this is your sign to start 😉&lt;/p&gt;

</description>
      <category>docker</category>
      <category>kubernetes</category>
      <category>dotnet</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
