0Pricing
AI Powered SaaS: Stripe + Auth + Billing + Deploy · درس

تطبيقات متعددة الحاويات باستخدام Docker Compose

استخدم Docker Compose لتعريف تطبيقات متعددة الخدمات وتشغيلها معًا، مثل التطبيق وقاعدة البيانات وذاكرة التخزين المؤقت، باستخدام ملف وصفي واحد.

تطبيقات متعددة الحاويات باستخدام Docker Compose درس مجاني في AI Powered SaaS: Stripe + Auth + Billing + Deploy على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في AI Powered SaaS: Stripe + Auth + Billing + Deploy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة AI Powered SaaS: Stripe + Auth + Billing + Deploy 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

Why Docker Compose?

Real apps rarely run in one container. You often need a web app, a database, and a cache. Docker Compose lets you define all of them in one YAML file and start them with a single command.

The compose.yaml File

Compose reads a file named compose.yaml (or docker-compose.yml). Each entry under services describes one container.

services:
  web:
    build: .
    ports:
      - "3000:3000"
  db:
    image: postgres:16

Defining a Service

A service can be built from a local Dockerfile or pulled as an existing image. You also set ports, environment variables, and dependencies here.

Environment Variables

Pass configuration with environment or load from an .env file. Never hardcode secrets directly in the YAML committed to git.

services:
  db:
    image: postgres:16
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}

Service Networking

Compose puts all services on a shared network. A service reaches another by its service name as the hostname. The web app connects to the database at db:5432.

Persisting Data with Volumes

Containers are ephemeral. Use a named volume so database data survives restarts and rebuilds.

services:
  db:
    image: postgres:16
    volumes:
      - dbdata:/var/lib/postgresql/data
volumes:
  dbdata:

Startup Order with depends_on

depends_on controls start order, but it does not wait for a service to be ready. Combine it with a healthcheck so the web app waits until the database accepts connections.

Bringing It Up and Down

Start everything in the background with up -d and stop with down. Add --build to rebuild images after code changes.

docker compose up -d --build
docker compose down

Viewing Logs

Aggregate logs from all services or follow one. This is essential for debugging how containers interact.

docker compose logs -f web

Scaling a Service

Run multiple copies of a stateless service to handle more load. Put a load balancer or reverse proxy in front to distribute traffic.

docker compose up -d --scale web=3

Compose for Dev vs Production

Use a base compose.yaml plus an override file for each environment. Development might mount source code for hot reload; production uses prebuilt images and stricter restart policies.

Quick Check

Check your Docker Compose knowledge.

Recap

You learned to orchestrate multi-container apps with Docker Compose:

  • Define services in compose.yaml
  • Connect them via service-name networking
  • Persist data with volumes and control order with depends_on/healthcheck
  • Use up, down, logs, and scaling

Compose makes local and production multi-service setups reproducible.

الأسئلة الشائعة

هل درس «تطبيقات متعددة الحاويات باستخدام Docker Compose» مجاني؟

نعم — نص درس «تطبيقات متعددة الحاويات باستخدام Docker Compose» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة AI Powered SaaS: Stripe + Auth + Billing + Deploy، انتقل إلى CoddyKit PRO. تتضمن دورة AI Powered SaaS: Stripe + Auth + Billing + Deploy 4 دروس في المجموع.

ماذا ستتعلم في «تطبيقات متعددة الحاويات باستخدام Docker Compose»؟

استخدم Docker Compose لتعريف تطبيقات متعددة الخدمات وتشغيلها معًا، مثل التطبيق وقاعدة البيانات وذاكرة التخزين المؤقت، باستخدام ملف وصفي واحد. تتمرن على AI Powered SaaS: Stripe + Auth + Billing + Deploy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ AI Powered SaaS: Stripe + Auth + Billing + Deploy؟

لا تُشترط خبرة سابقة. AI Powered SaaS: Stripe + Auth + Billing + Deploy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.

كم من الوقت يستغرق درس «تطبيقات متعددة الحاويات باستخدام Docker Compose»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس AI Powered SaaS: Stripe + Auth + Billing + Deploy هذا؟

نعم. كل درس في AI Powered SaaS: Stripe + Auth + Billing + Deploy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. تحويل تطبيقك إلى حاويات Docker
  2. مقدمة إلى موفّري الخدمات السحابية
  3. النشر على آلة افتراضية سحابية
  4. تطبيقات متعددة الحاويات باستخدام Docker Compose
← العودة إلى AI Powered SaaS: Stripe + Auth + Billing + Deploy