Git Product home page Git Product logo

learning-ec2-ecs's Introduction

learning-ec2-ecs

This repo is used to learn using the Amazon EC2 Container Service

Setup AWS

  1. Install AWS Command line interface

$ pip install --upgrade --user awscli

  1. Configure it with your credentials

$ aws configure

  1. Install AWS ECS Command line interface

$ sudo curl -o /usr/local/bin/ecs-cli https://s3.amazonaws.com/amazon-ecs-cli/ecs-cli-darwin-amd64-latest

  1. Apply execute permissions

$ sudo chmod +x /usr/local/bin/ecs-cli

How to

  1. Create your cluster. Use a EC2 Keypair pem file

ecs-cli up --keypair id_rsa --capability-iam --size 2 --instance-type t2.medium

  1. Create a compose file docker-compose.yml
version: '2'
services:
  wordpress:
    image: wordpress
    cpu_shares: 100
    mem_limit: 524288000
    ports:
      - "80:80"
    links:
      - mysql
  mysql:
    image: mysql
    cpu_shares: 100
    mem_limit: 524288000
    environment:
      MYSQL_ROOT_PASSWORD: password
  1. Deploy compose file to cluster

$ ecs-cli compose --file hello-world.yml up

  1. View the running containers on a cluster

$ ecs-cli ps

  1. Scale the tasks on the cluster

ecs-cli compose --file hello-world.yml scale 2

  1. Create an ECS Service from compose file

Stop all containers

$ ecs-cli compose --file hello-world.yml down

Create service

$ ecs-cli compose --file hello-world.yml service up

  1. Clean up

Delete the service

$ ecs-cli compose --file hello-world.yml service rm

Take down cluster

$ ecs-cli down --force

Amazon EC2 Container Registry

  1. Authenticate Docker to an Amazon ECR registry with get-login

$ aws ecr get-login

  1. Copy and paste the docker login command into a terminal to authenticate your Docker CLI to the registry.

  2. Create a repository

$ aws ecr create-repository --repository-name myrepo

  1. Push an image to Amazon ECR

$ docker images

Tag the image to push to your repository. Update it with your AWS account id and aws ECR domain.

$ docker tag myimage AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/myimage

Push the image.

$ docker push AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/myimage

  1. Pull an image from Amazon ECR

$ docker pull AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/myimage

  1. Delete an image

$ aws ecr batch-delete-image --repository-name myrepo --image-ids imageTag=myimage

  1. Delete repository

$ aws ecr delete-repository --repository-name myrepo --force

learning-ec2-ecs's People

Contributors

patrick-michelberger avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.