Connect EC2

Connect SSH to EC2

SSH

Install docker & git

  • Follows Command line:
    • sudo yum update
    • sudo yum install git -y
    • sudo yum install docker -y
  • Check version Install

Create Dockerfile, build Docker images, Docker container.

  • Git clone source code: https://github.com/hs-nguyen/Host-a-Static-Web-App-on-AWS-with-Docker-and-AWS-ECS.git Git
  • CLI: “Cd Host-a-Static-Web-App-on-AWS-with-Docker-and-AWS-ECS”
  • Create Dockerfile
    • FROM nginx:1.25.3
    • COPY ./ /usr/share/nginx/html
    • EXPOSE 80
    • CMD [“nginx”, “-g”, “daemon off;”]
  • Check Docker Docker
  • Build Docker images & Docker container
  • Follows CLI
    • CLI: docker build -t web-app . (Build Docker images)
    • CLI: docker run -d –name web-app -p 8080:80 web-app (Run Docker container)
    • CLI: docker ps-a (Check status container)
  • Check Container
  • Custom inbound rules for security group for EC2
    • Add inbound rules:
      • Types: Custom TCP
      • Protocol: TCP
      • Port range: 8080
      • Source: Anywhere
  • Security group
  • Access to Website through IP public EC2
  • IP Pubblic