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.
-
Add user
-
Create a public/private key.
-
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
1:43:
chmod +x install-docker.sh ./install-docker.sh
-
Edit file
0:28:
sudo nano /etc/group
-
Add line:
docker:x:999:ubuntu
-
exit
-
Login again (substituting your IP address):
ssh -i newcluster.pem ubuntu@34.207.122.35
-
Run (launch) a small Docker hello-world:
1:41:
docker run hello-world docker info
-
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 -
Back at local prompt:
2:50:
docker info docker ps docker rename goofy_mccarthy newname # substitute docker inspect newname | less
-
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",
-
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
-
Instantiate a webserver:
DOCKER_SERVER_NAME="webserver" DOCKER_SERVER_PORT="80" docker build -t "$DOCKER_SERVER_NAME" . docker images
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 ..
-
Create wordpress with one command:
1:12
docker run -it wordpress /bin/bash # for root@a2c20e10a430 substituted exit
-
Instatiate
docker-container-build.sh
-
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.
-
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
-
Get IP address for "en0" : http://192.168.1.16 for "Welcome to my website"
ip a
-
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
-
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."
-
Get an AWS account.
-
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
-
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
ecs-params.yml
ecs-ec2-launch.sh
ecs-fargate-launch.yml
ecs-fargate-launch.sh
install-ecs-utils.sh
eksctl-create-cluster.sh
Apache/Dockerfile
Apache/docker-compose.yml
ecr-auth-admin.sh