section 18 docker,eks

Cards (238)

  • Docker
    A software development platform to deploy apps using container technology
  • Docker containers
    • Apps are packaged into containers
    • Containers are standardized and can run on any operating system
    • Containers have predictable behavior and are easy to maintain and deploy
    • Can run with any language, operating system, or technology
  • Use cases for Docker
    • Microservice architecture
    • Lift and shift apps from on-premises to the cloud
    • Anytime you want to run a container
  • How Docker works on an operating system
    1. Run a Docker agent on a server (e.g. EC2 instance)
    2. Start Docker containers, which can contain different applications (e.g. Java, Node.js)
    3. Can also run databases in Docker containers
  • Docker Repository
    Where Docker images are stored, options include Docker Hub (public) and Amazon ECR (private)
  • Docker vs Virtual Machines
    • Docker is a virtualization technology but resources are shared with the host, allowing more containers to run on a single server
    • Virtual machines have a hypervisor and separate guest operating systems, providing more isolation but less resource efficiency
  • Getting started with Docker
    1. Write a Dockerfile to define the container
    2. Build the Docker image from the Dockerfile
    3. Store the Docker image in a repository (Docker Hub or Amazon ECR)
    4. Pull the Docker image from the repository and run it as a container
  • Docker container management on AWS
    • Amazon ECS (Elastic Container Service)
    • Amazon EKS (Elastic Kubernetes Service)
    • AWS Fargate (serverless container platform)
    • Amazon ECR (Elastic Container Registry to store container images)
  • Docker containers
    Lightweight, portable, and isolated runtime environments for running applications
  • Docker images
    Templates used to create Docker containers
  • Docker images and containers
    Together, they enable developers to package, deploy, and manage applications consistently across different environments
  • Docker images
    • Read-only templates used to create Docker containers
    • Contain application code, runtime, dependencies, libraries, and other configuration files needed to run an application
    • Built using Dockerfile, a text file with instructions for building the image layer by layer
    • Stored in repositories like Docker Hub or Amazon ECR, can be shared, versioned, and reused
    • Immutable, any changes result in a new image with a new tag/version
  • Docker containers
    • Lightweight, standalone, and executable software packages that contain everything needed to run an application
    • Provide a consistent environment for applications to run across different computing environments
    • Isolate applications from the underlying infrastructure, ensuring consistent execution
    • Portable and can be easily deployed on any system that supports Docker
  • Building Docker images
    1. Use Dockerfiles to define the instructions
    2. Docker images can be deployed and run on various platforms, including AWS
  • Docker container
    • Still have the infrastructure and the host OS, which may be an EC2 instance
    • Have the Docker Daemon, and on top of it, many lightweight containers that can cohabitate together, sharing networking and data
  • Docker containers vs virtual machines
    Less secure than virtual machines, but allow running more containers on a single server
  • Docker commands
    1. docker run: Start a container from a Docker image
    2. docker build: Build a Docker image from a Dockerfile
    3. docker push: Push a Docker image to a registry
    4. docker pull: Pull a Docker image from a registry
  • docker-compose
    Manage multi-container Docker applications
  • Docker containers
    Lightweight, portable, and isolated runtime environments for running applications
  • Docker images
    Templates used to create Docker containers
  • Docker images and containers
    Together, they enable developers to package, deploy, and manage applications consistently across different environments
  • Docker images

    • Read-only templates used to create Docker containers
    • Contain application code, runtime, dependencies, libraries, and other configuration files needed to run an application
    • Built using Dockerfile, a text file with instructions for building the image layer by layer
    • Stored in repositories like Docker Hub or Amazon ECR, can be shared, versioned, and reused
    • Immutable, any changes result in a new image with a new tag/version
  • Docker containers
    • Lightweight, standalone, and executable software packages that contain everything needed to run an application
    • Provide a consistent environment for applications to run across different computing environments
    • Isolate applications from the underlying infrastructure, ensuring consistent execution
    • Portable and can be easily deployed on any system that supports Docker
  • Building Docker images

    1. Use Dockerfiles to define the instructions
    2. Docker images can be deployed and run on various platforms, including AWS
  • Docker container
    • Still have the infrastructure and the host OS, which may be an EC2 instance
    • Have the Docker Daemon
    • Can have many lightweight containers running on top of the Docker Daemon, sharing networking and data
  • Docker containers vs virtual machines
    Less secure than virtual machines, but allow running more containers on a single server
  • Docker commands
    1. docker run: Start a container from a Docker image
    2. docker build: Build a Docker image from a Dockerfile
    3. docker push: Push a Docker image to a registry
    4. docker pull: Pull a Docker image from a registry
    5. docker-compose: Manage multi-container Docker applications
  • ECS
    Elastic Container Service
  • Launch Docker containers on AWS
    Launch ECS Tasks on ECS Clusters
  • EC2 Launch Type
    • You must provision & maintain the infrastructure (the EC2 instances)
    • Each EC2 Instance must run the ECS Agent to register in the ECS Cluster
    • AWS takes care of starting / stopping containers
  • Fargate Launch Type
    • You do not provision the infrastructure (no EC2 instances to manage)
    • It's all Serverless!
    • You just create task definitions
    • AWS just runs ECS Tasks for you based on the CPU / RAM you need
    • To scale, just increase the number of tasks. Simple - no more EC2 instances
  • IAM Roles for ECS
    • EC2 Instance Profile (EC2 Launch Type only)
    • ECS Task Role
  • EC2 Instance Profile (EC2 Launch Type only)

    • Used by the ECS agent
    • Makes API calls to ECS service
    • Send container logs to CloudWatch Logs
    • Pull Docker image from ECR
    • Reference sensitive data in Secrets Manager or SSM Parameter Store
  • ECS Task Role
    • Allows each task to have a specific role
    • Use different roles for the different ECS Services you run
    • Task Role is defined in the task definition
  • Data Volumes (EFS)

    • Mount EFS file systems onto ECS tasks
    • Works for both EC2 and Fargate launch types
    • Tasks running in any AZ will share the same data in the EFS file system
    • Fargate + EFS = Serverless
    • Use cases: persistent multi-AZ shared storage for your containers
  • Amazon S3 cannot be mounted as a file system
  • ECS Cluster
    A logical grouping of EC2 instances or AWS Fargate tasks where you can run containerized applications
  • ECS Cluster
    • Acts as the infrastructure foundation for running your containers and managing resources
    • You can have multiple clusters within an AWS account, each serving different purposes or environments
  • Task (in ECS)
    A logical grouping of Docker containers that are scheduled together on the same EC2 instance or Fargate task
  • Task (in ECS)
    • Tasks are the basic unit of work in ECS
    • You define tasks using task definitions