DevOps

    ECS Task Definitions: Defining Your Containers


    Key Parameters

    • Container definitions: Image, ports, CPU/memory.
    • Volumes, networking, etc.

    Step 1: Create Task Definition

    JSON example for our app:

    { "family": "my-task", "containerDefinitions": [ { "name": "my-container", "image": "<account-id>.dkr.ecr.us-west-2.amazonaws.com/my-app-repo:latest", "cpu": 256, "memory": 512, "portMappings": [{ "containerPort": 3000, "hostPort": 3000 }], "essential": true } ], "requiresCompatibilities": ["FARGATE"], "networkMode": "awsvpc", "cpu": "256", "memory": "512"}

     

    Register via CLI:

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

    Step 2: Run a Task

    Console: ECS > Clusters > my-cluster > Tasks > Run new task > Select definition.

    CLI:

     aws ecs run-task --cluster my-cluster --task-definition my-task --launch-type FARGATE --network-configuration "awsvpcConfiguration={subnets=[subnet-id],securityGroups=[sg-id],assignPublicIp=ENABLED}"

     

    Check logs in console.

    Ready to transform your business with our technology solutions? Contact Us  today to Leverage Our DevOps Expertise. 

    Contact Us

    Comment

    Share

    facebook
    LinkedIn
    Twitter
    Mail
    Devops

    Related Center Of Excellence