DevLearn
Cloud Deployment

Deploy Docker to Cloud

Deploy containerized applications to AWS, Azure, GCP, and Kubernetes clusters.

AWS ECS

Elastic Container Service

Azure ACI

Container Instances

GCP Cloud Run

Serverless containers

Kubernetes

Container orchestration

AWS ECS / Fargate

Deploy containers to AWS without managing servers

# AWS ECS Deployment

# Task Definition
{
  "family": "myapp",
  "containerDefinitions": [
    {
      "name": "app",
      "image": "myapp:latest",
      "essential": true,
      "portMappings": [
        {
          "containerPort": 3000,
          "protocol": "tcp"
        }
      ],
      "logConfiguration": {
        "logDriver": "awslogs",
        "options": {
          "awslogs-group": "/ecs/myapp",
          "awslogs-region": "us-east-1",
          "awslogs-stream-prefix": "ecs"
        }
      }
    }
  ],
  "requiresCompatibilities": ["FARGATE"],
  "networkMode": "awsvpc",
  "cpu": "256",
  "memory": "512"
}

# Create ECS cluster
aws ecs create-cluster --cluster-name production

# Register task definition
aws ecs register-task-definition --cli-input-json file://task-def.json

# Create service
aws ecs create-service \
  --cluster production \
  --service-name myapp \
  --task-definition myapp \
  --desired-count 3 \
  --launch-type FARGATE

ECS Features

  • Fargate - serverless
  • EC2 - more control
  • Service auto-scaling

Best Practices

  • Use ECR for images
  • Enable logging
  • Set resource limits

Deployment Checklist

Configure resource limits
Set up health checks
Enable logging
Use secrets for credentials
Implement graceful shutdown
Configure auto-scaling
Set up monitoring
Document rollback procedure
Test disaster recovery
Enable container security