Giter Site home page Giter Site logo

docker-ecs-projects's Introduction

Docker to AWS ECS project

Run application using docker on EC2 server

Steps

  1. Create an EC2 server on the AWS Console (make sure you open port 80 in your security group)
  2. ssh into the server
  3. install git using the following command:
    • sudo yum install git
  4. clone the code to the server
  5. install docker on the server using the following commands:
    • sudo yum update
    • sudo yum install docker -y
    • sudo systemctl start docker
    • sudo usermod -aG docker ec2-user
    • exit (exit from server and ssh again)
  6. Create a private ECR repository on the AWS console with any name (like node-react-app)
  7. configure your AWS credentials using the export commands or the aws configure command:
    • export AWS_ACCESS_KEY_ID=your-access-key
    • export AWS_SECRET_ACCESS_KEY=your-secret-key
    • export AWS_DEFAULT_REGION=your-ecr-region
  8. go to the ecr repo and copy push commands from ecr and paste in the location where docker file exists for login, build, tagging and push the image to ecr (inside the repository you cloned)
  9. after running all commands, check the ecr repo and confirm the image exists
  10. Run the docker run command to start the container
    • docker run -d -p 80:80 node-react-app:latest
  11. after starting the container, copy the public ip of the EC2 server and paste in a browser to see if the app is working or not.

Run the application using ECS (Migrating the application to ECS)

  1. Create an ECS cluster
    • enter the name
    • select any vpc and subnets
    • select fargate from AWS Infrastructure
  2. Create a task definition
    • Enter the name
    • In container 1, enter a container name
    • copy the ecr image url and tag and paste in image URI
    • container port 80
    • select the app environment fargate
  3. Create a service inside the cluster
    • select launch type fargate
    • select application type Service
    • in family, select the task definition you created earlier
    • type a service name
    • in the load balancer section, select application load balancer
    • create new and enter a name name
    • select create new target group and enter a name
    • Create the service
  4. Go to load balancer in EC2, copy the dns name and paste in a browser to see the application working.

docker-ecs-projects's People

Contributors

olayusuf22 avatar

Watchers

 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.