Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

This README.md page at https://github.com/wilsonmar/DevSecOps/blob/master/docker4aws/README.md describes the repository https://github.com/wilsonmar/DevSecOps/master/docker4aws

This repository (docker4aws) contains files copied from the https://bootstrap-it.com/docker4aws web page created by David Clinton as part of his 12 June 2019 video class on Pluralsight "Using Docker on AWS". The description for the class is:

"Get yourself up to speed running your Docker workloads on AWS. Learn the CLI tools you'll need to manage containers using ECS - including Amazon's managed container launch type, Fargate - and Kubernetes (EKS) and the ECR image repo service."

The scripts here automate the creation of a WordPress image from DockerHub at https://hub.docker.com/_/wordpress/

Links to the specific video making use of the file is provided. But know you need a subscription to Pluralsight to see the video.

There are two versions of the files: the original with hard-coded values, and one containing variables so you can reuse the files here for your own projects.

  1. Add user

  2. Create a public/private key.

  3. Get into a new instance (subsituting the IP address) on Windows: 1:08:

    ssh -i newcluster.pem ubuntu@34.207.122.35

    On a Mac:

    ssh -i newcluster ubuntu@34.207.122.35

https://docs.docker.com/install/linux/docker-ce/ubuntu

Script for installing Docker on Ubuntu

1:43:

chmod +x install-docker.sh
./install-docker.sh

A simple Dockerfile

  1. Edit file 0:28:

    sudo nano /etc/group
  2. Add line:

    docker:x:999:ubuntu
  3. exit

  4. Login again (substituting your IP address):

    ssh -i newcluster.pem ubuntu@34.207.122.35
  5. Run (launch) a small Docker hello-world:1:41:

    docker run hello-world
    docker info
    
  6. Get inside the image:2:11:

    docker run -it ubuntu bash
        # for> root@7f23d646e7d3:/#
    ls  # for> bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
    apt update
    exit
  7. Back at local prompt:2:50:

    docker info
    docker ps
    docker rename goofy_mccarthy newname  # substitute
    docker inspect newname | less
    
  8. Network:3:50:

    docker network ls
    

docker network create newnet docker inspect newnet | less # "Driver": "bridge", "Subnet": "172.18.0.0/16", # substituted docker network connect newnet newname # no response if good. docker inspect newname # should show both addresses ping 172.18.0.2 # substitute from "IPAddress": "172.18.0.2", ping 172.17.0.2 # substitute from "IPAddress": "172.17.0.2",

  1. Create or navigate to a folder "simple" and download the Dockerfile 0:10

    cd simple  # in repo for Dockerfile inside
    curl -O https://raw.githubusercontent.com/wilsonmar/DevSecOps/master/docker4aws/simple/Dockerfile
    
  2. Instantiate a webserver:

DOCKER_SERVER_NAME="webserver" DOCKER_SERVER_PORT="80" docker build -t "$DOCKER_SERVER_NAME" . docker images

specify -p after -d :

docker run -d -p "$DOCKER_SERVER_PORT:80" "$DOCKER_SERVER_NAME" /usr/sbin/apache2ctl -D FOREGROUND curl localhost # RESPONSE="Welcome to my web site" cd ..

Build and run wordpress locally

  1. Create wordpress with one command: 1:12

    docker run -it wordpress /bin/bash  # for root@a2c20e10a430  substituted
    exit
    
  2. Instatiate

docker-container-build.sh

WordPress stack.yml file for local deployment

  1. Instantiate wordpress and mysql 5.7 locally *

    curl -O https://raw.githubusercontent.com/wilsonmar/DevSecOps/master/docker4aws/stack.yml
    

    NOTE: The image of the stack.yml file on the video does not show the "---" on the first line which defines yml files.

    NOTE: Credentials inside yml files are insecure.

  2. To avoid "this node is not a swarm manager. Use "docker swarm init" or "docker swarm join" to connect this node to swarm and try again"2:21

    docker swarm init
    docker stack deploy -c stack.yml mywordpress
    
  3. Get IP address for "en0" : http://192.168.1.16 for "Welcome to my website"

    ip a

ecs-cli-config.sh for EC2 launch type

  1. Install AWS-CLI and ECS-CLI on your machine: 3:40

    https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ECS_CLI_installation.html

    curl -O https://raw.githubusercontent.com/wilsonmar/DevSecOps/master/docker4aws/ecs-cli-config.sh
    chmod +x ecs-cli-config.sh
    ./ecs-cli-config.sh
  2. Define the configuration:

    curl -O https://raw.githubusercontent.com/wilsonmar/DevSecOps/master/docker4aws/ecs-cli-config-ec2.sh
    chmod +x ecs-cli-config-ec2.sh
    ./ecs-cli-config-ec2.sh

    RESPONSE: "INFO[0000] Saved ECS CLI cluster configuration ec2-test-App."

  3. Get an AWS account.

  4. Get and edit file ecs-cli-config-profile.sh with your own AWS access key and secret key:4:20

    curl -O https://raw.githubusercontent.com/wilsonmar/DevSecOps/master/docker4aws/ecs-cli-config-profile.sh
    nano ecs-cli-config-profile.sh
    
  5. Get and edit file ecs-cli-config-profile.sh with your own AWS access key and secret key:4:20

    curl -O https://raw.githubusercontent.com/wilsonmar/DevSecOps/master/docker4aws/ecs-cli-compose.sh
    chmod +x ecs-cli-compose.sh
    ./ecs-cli-compose.sh
    

    curl -O https://raw.githubusercontent.com/wilsonmar/DevSecOps/master/docker4aws/ecs-ec2-launch.yml ecs-ec2-launch.yml

docker-compose.yml for EC2 launch

docker-compose.yml

ecs-params.yml for EC2 launch

ecs-params.yml

Launch EC2 type

ecs-ec2-launch.sh

YAML files for Fargate

ecs-fargate-launch.yml

Launch Fargate type

ecs-fargate-launch.sh

Install eksctl, kubectl, and aws-iam-authenticator

install-ecs-utils.sh

Build Kubernetes cluster and download YAML files

eksctl-create-cluster.sh

Build Apache webserver container on Docker CE

Apache/Dockerfile

Apache on ECS

Apache/docker-compose.yml

ECR authentication and administration

ecr-auth-admin.sh