Containers on Compute
Containers without the cluster
Managed container services (ECS Fargate, ACI, Cloud Run) run containers without managing servers — a middle ground between worry-free functions and portability-through-needing-a-cluster.
What you will learn
- Compare serverless containers vs VMs vs functions
- Explain ECS/Fargate, ACI, Cloud Run models
- Choose the right container compute tier
Serverless containers remove the node: you define a container (image, CPU, memory), the platform schedules and scales it per request or task. No clusters, no nodes, no patching.
What is this?
AWS ECS on Fargate (serverless) or EC2 (you manage nodes); Azure Container Instances (ACI) and Container Apps; GCP Cloud Run (request-driven serverless containers) and Cloud Run services. Container compute sits between VMs (full control, operational burden) and functions (no control, no containers). Scaling is per-container replica driven by requests, events, or schedules.
Why do you need it?
- Packaging via Dockerfiles: reproduce exact runtime, test locally.
- No node patching or capacity guessing — the platform provides it.
- Faster cold start than full VMs, more control than functions.
- Portable image moves between dev, CI, and prod consistently.
Mental model
Prepacked meal kits delivered fresh on demand
Serverless containers
The kit (image) is prepared anywhere and delivered (scheduled) as needed — someone else runs the kitchen (the platform), you just order replicas.
How it works
- You push an image to a registry; the task/revision/service definition lists image, ports, CPU/RAM, env.
- Fargate provisions the exact resources per task (vCPU/memory) and runs your container in isolation.
- Cloud Run scales from zero to N replicas based on incoming HTTP; each replica autoconcurrency-controlled.
- ACI runs single containers and container groups for short-lived or scheduled jobs.
- Platform handles placement, scaling, health, patching of the runtime — you own only the image.
Comparing compute tiers.
Examples
Run a container without a server
# AWS ECS on Fargateaws ecs create-service --cluster prod --service-name web --task-definition web-task --launch-type FARGATE --desired-count 3 --network-configuration ...# Azure Container Instancesaz container create -n web -g app-rg --image nginx:alpine --cpu 1 --memory 1 --ports 80# GCP Cloud Rungcloud run deploy web --image gcr.io/myproj/web:1.4 --region us-central1 --allow-unauthenticatedThe image is everything; the platform handles scheduling and lifecycle.
In production
- A payments worker runs as Fargate tasks triggered by SQS with per-task memory sized to the job.
- Cloud Run serves a webhook API scaling to zero in quiet hours.
- ACI runs scheduled ETL from an Azure container group with health probes.
Best practices
- Keep images small, immutable, and cross-arch (multi-arch manifests).
- Set CPU/memory from real profile; Fargate/Cloud Run bill per allocated unit.
- Prefer per-request concurrency on Cloud Run for efficient cold reuse.
- Use health checks and min-instances only where latency demands.
Common mistakes
- Choosing serverless containers for long-running stateful databases.
- Ignoring cold-start: 0% min instances is great for cost, wrong for latency SLAs.
- Fat images (GBs) starving Fargate start and Cloud Run cold-start times.
- Port mapping confusion: ECS networking vs Cloud Run generated URLs.
Common issues
Container restarts in loopUnhealthy app with failing health check
Inspect logs; ensure the health-check endpoint responds on the port the platform probes.
Cloud Run cold start exceeds SLAScaling from zero with large image
Set min-instances and startup probe, shrink image, or enable warm pools.
Debugging tips
- Cold start slow? Debug image size and startup script, not just replica count.
- OOM on Fargate/ACI? Increase task memory or inspect container logs for limits.
- Cloud Run scaling noises: check concurrency setting vs max-instances race.
- Use the platform's built-in tracing (Run traces, ECS log driver) to correlate request→container.
Interview checkpoint
Quick quiz
What does 'serverless container' mean operationally?