Using Docker on AWS

NTRODUCTION

THE BASICS

By scmGalaxy.com

About Me

DevOps@RajeshKumar.XYZ

Overview

  • This module:
    • Install Docker
    • Configure and launch container
    • Dockerfiles
    • Docker Hub

Overview

  • Later modules:
    • Amazon ECS (EC2 Container Service)
      • tasks
      • file systems
      • repositories
    • Deploy web app to a cluster
    • AWS optimization
    • Docker Hub and EC2 Container Registry

Lab Setup Information

https://bootstrap-it.com/docker4aws

What Is Docker?

Type 1 Hypervisor

docker aws hypervisor

Type 2 Hypervisor

docker aws type 2 hypervisor

Containers

docker aws containers

Docker Collaboration

docker aws collaborationy

Installing Docker on an EC2 Instance

  • Install Docker on an EC2 Ubuntu instance
  • Best security practices
  • Launch "Hello World" container
  • Docker command line

Running Docker from the Command Line

A Sample Dockerfile

  • # Simple Dockerfile
  • #
  • FROM ubuntu:16.04
  • RUN apt update
  • RUN apt install -y apache2
  • RUN echo "Welcome to my web site" > /var/www/html/index.html
  • EXPOSE 80
  • Launch Docker
  • Pull and run Ubuntu image
  • Create network interface
  • Add interface to container

Working with Dockerfiles

Working with Docker Hub Images

Summary

    Containers vs. Hypervisors

  • Docker on AWS:
    • EC2 Container Service
    • Elastic Beanstalk
    • CloudFormation
    • Docker for AWS
    • Docker Datacenter for AWS

Summary

  • apt install apt-transport-https ca-certificates
  • apt install linux-image-extra-$(uname -r) linuximage- extra-virtual
  • apt install docker-engine
  • docker info
  • docker run -it ubuntu bash
  • docker network connect newnet newname
  • nano dockerfile
  • docker run -d -p 80:80 webserver /usr/sbin/apache2ctl -D FOREGROUND

Amazon ECS: Exploring the Environment

Cluster Computing

docker aws cluster computing

Cluster Computing

docker cluster computing

Cluster Computing

docker aws cluster computing

Cluster Computing

 cluster computing of docker

Cluster Coordination

docker cluster coordination

Cluster Coordination

docker aws cluster coordination

Cluster Computing Goals

  • High Availability
    • Providing for failover and replacement resources
  • Scalability

    • Providing for added compute capacity on demand
  • Load Balancing

    • Providing for intelligently routed network traffic

EC2 Container Service: Defining Terms

How ECS Works

Your EC2 instance running the Amazon ECS container agent has been registered into a cluster so that a task definition can be instantiated by a pre-configured service request and monitored until it's done.

Overview

  • Understand ECS infrastructure elements
  • Deploy an actual ECS application

Cluster Coordination

docker cluster coordination of cluster agent

Cluster

docker aws cluster task

Cluster

docker aws cluster task service

Cluster

docker aws cluster task one

Cluster

docker cluster one and cluster two

Cluster

docker aws cluster task

Cluster

docker cluster task container

Cluster

docker cluster task container service

Summary

  • Cluster design paradigms
    • high availability
    • scalability
    • load balancing
  • EC2 Container Service (ECS)
    • cluster
    • task
    • service
  • Identity and Access Management (IAM)

Amazon ECS: Building a Cluster Environment

Updated Dockerfile

  • # Simple Dockerfile
  • #
  • FROM ubuntu:16.04
  • RUN apt update
  • RUN apt install -y apache2
  • RUN echo "Welcome to my web site" > /var/www/html/index.html
  • CMD /usr/sbin/apache2ctl -D FOREGROUND
  • EXPOSE 80

Overview

  • Launch EC2 instance
  • Create IAM role
  • Define task
  • Create service
  • Explore Command Line Interface (CLI)

Building an EC2 Container Service

ECS and the AWS Command Line Interface

Summary

  • AmazonEC2ContainerServiceforEC2Role
  • dbclinton/newserver
  • /usr/sbin/apache2ctl -D FOREGROUND
  • Cluster | Service | Events
  • aws ecs describe-instances

Working with Docker Images and Registries

Updated Dockerfile

  • # Simple Dockerfile
  • #
  • FROM ubuntu:16.04
  • RUN apt update
  • RUN apt install -y apache2
  • RUN echo "Welcome to my web site" > /var/www/html/index.html
  • CMD /usr/sbin/apache2ctl -D FOREGROUND
  • EXPOSE 80

Overview

  • Work with Docker Hub repositories
  • Work with the Amazon EC2 Container Repository service
  • Private Docker Hub repositories
    • ECS access

Working with Docker Hub Repositories

Configure ECS to Authenticate with Docker Hub

Amazon EC2 Container Registry (ECR)

  • Create a repository
  • Connect to a repository
  • Apply a tag to an image
  • Push to an ECR repository
  • Pull into an ECS container

Summary

  • docker login
  • docker tag 1f9bd3ea1a9d dbclinton/newerserverdocker
  • push dbclinton/newerserver
  • nano /etc/ecs/ecs.config
  • ECS_ENGINE_AUTH_TYPE=docker
  • Amazon EC2 Container Registry (ECR)
  • aws ecr get-login --region us-east-1

Course Review

Containers

docker containers

Cluster Computing Goals

  • High Availability
    • Providing for failover and replacement resources
  • Scalability
    • Providing for added compute capacity on demand
  • Load Balancing
    • Providing for intelligently routed network traffic

A Sample Dockerfile

  • # Simple Dockerfile
  • #
  • FROM ubuntu:16.04
  • RUN apt update
  • RUN apt install -y apache2
  • RUN echo "Welcome to my web site" > /var/www/html/index.html
  • EXPOSE 80

Cluster Coordination

docker aws cluster coordination

Cluster

docker cluster task container service

questions?

docker questions

Thanks for You