Docker, Nginx and WordPress


object In AWS ECS
  1. A server which is a type of long-running program called a daemon process.
  2. A REST API which specifies interfaces that programs can use to talk to the daemon and instruct it what to do.
  3. A command line interface (CLI) client.The Docker client can either be installed local to the daemon, or on a different host altogether.
dockerfile A Dockerfile is a text file that describes how to “build” the image. tasks?
libcontainer Execution environment of container; interface to various Linux kernel isolation features, like namespaces and cgroups
Linux cgroup (abbreviated from control groups) is a Linux kernel feature that limits, accounts for and isolates the resource usage (CPU, memory, disk I/O, network, etc.) of a collection of processes.
Linux namespaces are a feature of the Linux kernel that isolates and virtualizes system resources of a collection of processes. Examples of resources that can be virtualized include process IDs, hostnames, user IDs, network access, interprocess communication, and filesystems. Namespaces are a fundamental aspect of containers on Linux.
Image build component of a container. It is a read-only template from which one or more container instances can be launched. Conceptually, it’s similar to an AMI.
Registry used to store images. Registries can be local or remote. When we launch a container, Docker first searches the local registry for the image. If it’s not found locally, then it searches a public remote registry, called DockerHub. If the image is there, Docker downloads it to the local registry and uses it to launch the container.
Container is a running instance of an image. Docker uses containers to execute and run the software contained in the image.


Setup CLI –

  1. Install python
  2. Install pip
  3. yum install aws-cli
  4. aws configure (setup access key ID, access key and default region)
  5. aws ec2 describe-instances
  6. aws ecs  list-container-instances
  7. aws ecs describe-container-instances –cluster wordpress –container-instances e22a5fc8-3655-4941-aabd-c91b591e39dc

  1. Create ECS cluster using GUI or CLI
  2. aws ecs create-cluster –cluster-name “wordpress”
  3. Create task definition Tell ECS how to run containers that comprise wordpress application – create task definition
  4. Create service


 “containerDefinitions”: [
     “name”: “wordpress”,
     “links”: [
     “image”: “wordpress”,
     “essential”: true,
     “portMappings”: [
         “containerPort”: 80,
         “hostPort”: 80
     “memory”: 400,
     “cpu”: 10
     “environment”: [
         “name”: “MYSQL_ROOT_PASSWORD”,
         “value”: “password”
     “name”: “mysql”,
     “image”: “mysql”,
     “cpu”: 10,
     “memory”: 400,
     “essential”: true
 “family”: “wordpressFamily”


Sample YML


version: ‘2
   image: wordpress
   cpu_shares: 100
   mem_limit: 404288000
     – “80:80”
     – mysql
   image: mysql
   cpu_shares: 100
   mem_limit: 404288000
     MYSQL_ROOT_PASSWORD: password


Sample YML


version: ‘2
   image: ‘mysql:5.7’

   cpu_shares: 100
   mem_limit: 404288000
   image: wordpress:4.6-fpm

   cpu_shares: 100
   mem_limit: 404288000
     – ‘./data/html:/var/www/html’
   image: bcardiff/nginx-4-wordpress-fpm

   cpu_shares: 100
   mem_limit: 404288000
     – PHP_FPM_SOCK=php-fpm:9000
     – 8080:80
     – ‘./data/html:/var/www/html’



Container instance – EC2 instance

Cluster – resource pool

Task definition version – code version



  1. Set desired count to 0 so that you can delete a ‘service’ from a cluster




Update ECS container agent before you go?


sudo yum install aws-cli

aws configure

aws ec2 describe-instances


sudo curl -o /usr/local/bin/ecs-cli


sudo chmod +x /usr/local/bin/ecs-cli


ecs-cli configure –region us-east-1 –access-key $AWS_ACCESS_KEY_ID –secret-key $AWS_SECRET_ACCESS_KEY –cluster ecs-cli-dchang


ecs-cli up –keypair dchangwebmd –capability-iam –size 1 –instance-type t2.small


Note that dchangwebmd is imported via AWS console


ecs-cli compose –file hello-world.yml up

ecs-cli compose –file hello-world.yml –project-name dchang-hello up

ecs-cli compose –file hello-world.yml –project-name dchang-hello down

Note – project-name = task definition name; it will be prefixed by whatever set in .ecs/config

ecs-cli compose –file hello-world.yml –project-name dchang-hello service up (this will start container from scratch every time; data will be erased)



Build a docker image


sudo usermod -a -G docker ec2-user – enable ec2-user to run docker command


docker images – show what you have on the ec2 instance

docker info – show the system info


sudo yum install -y git

git clone

cd ecs-demo-php-simple-app

docker build -t .

docker build -t dchangusc .

docker tag dchangusc:latest dchangusc

To tag a local image with name “dchangusc” and tag “latest” into the “” repository with “version1.0.test”:


aws ecr get-login –region us-east-1


docker tag dchangusc:latest


docker push


docker rmi (remove images)


docker login -u AWS -p AQECAHhwm0YaISJeRtJm5n1G6uqeekXuoXXPe5UFce9Rq8/14wAAAw0wggMJBgkqhkiG9w0BBwagggL6MIIC9gIBADCCAu8GCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQMxZbkRPnqs5jeF88sAgEQgIICwHbybvJc7qMmPfzs86jNTMr2w9Ovxc0haEutw58Mli/wghTmVSdkQeW8e7JnT4X3oOMJIEQePGBWKrC2ep1uo1JGx3CWNpyh0a7ydIPoatULH2g+V7sGh2ydWA0xBzW7bQppD2BR1tX3WrfhKp4Y7Agwh+P7H+txPd3mEiibv89ZIsVWMYKTgZT2NeAEJoMDcMEViYtjOk4ul+EyxeRMJRpL+P76iCPDYNVQcBcaaoXPsyHBA71qiNEgqJPCqrlKpgE5E1V9E8O+zyTLi9JVs3csqtMnud+AhqJeBrkprfqkaLffBXkDUc8meGwetmj82IF9KBdYRx7Bmuw7eXCYFAH+w2LPeJSIStoSJ/1tQFC5zjSDgAapBU34ixcG6Kx2Aj6AAxTpUxeiMpPQgM2iOKMUDG9LoDUl7jF1Pmgr57bUQResTnq2i/sGKvmQTqFanB1njdMktRx+ByxkMQ4Cd3+Dghhy4SrcVDrxxOARQGEnS9aDieGYAjLoXpWgEmXavg/HQO7CG66DprXZGNvyRrS8yj3QsXGv32eeaiTV+z+KE3BE5M0WfliSl0XpVvQSxe9SPitxbs9hhSHikTEZZgrnEKKctI4wlr4MEXBaMD6IiLFhEtEg1Ob/1V7H6YqOT1OfQTACp0+PT0WZOCsdHR9VyUd5/wttxIUN2hrutjWaT5sDet9bvfErRrVrXpDWq2mU2IudBZpNxB+qsNrpHiZkdHNoQ0FRtaa4LNAY9+83JGCVt7GxlU446bBk2fcGFbLteKCsqmt5rka+fYx7vwmTFS5XR8a9Nhalg0CiZf/4YwhekiiplOaiYl1LzeuC0Fn7Cu2g6SycF/qFuND1x15Gzu2lwU0w9eX1i9k8ZhOlT3hTgRGUzy2db7YfgiXyck+CHErKjriyQuPu20ZKLZND6KfC7B5paszwAMzr9wOx -e none


Sample .bash_profile

# .bash_profile


# Get the aliases and functions

if [ -f ~/.bashrc ]; then

       . ~/.bashrc



# User specific environment and startup programs








aws ecs list-clusters

aws ecs list-services –cluster ecs-cli-dchang

aws ecs list-tasks –cluster ecs-cli-dchang


aws ecs stop-task  –cluster ecs-cli-dchang –task 0be6c2a5-4e49-43af-9c5c-19fe247db194





  • Email to Sean 2017 budget
  • Email to cloud working group – survey, Roe and Thomas
  • Email to tech senior management at AWS conference
  • Email to Rick 2017 projects (slides, Madhura’s feedback)
  • Email to finance – 2017 budget
  • Email to Paul Mort about qa environment and CD pipeline
  • Check Madhura’s writing (load testing data)
  • Check Roger’s forms additional headcount
  • Check Madhura’s forms additional headcount – for ongoing and site performance project
  • Accomplishment table (Madhura)
  • Writing in load testing data (Madhura)
  • API testing data (Derek)
  • Real Device load testing for mobile web – requested by Mahesh. Marquee video is the use case. (Derek)
  • 2017 project table (Derek)
  • QA environment cost anaysis
  • Jacek – CI pipeline end to end





Sample YML

image: nginx
  – ./mysite.template:/etc/nginx/conf.d/mysite.template
  – “8080:80”
 command: /bin/bash -c “envsubst < /etc/nginx/conf.d/mysite.template > /etc/nginx/conf.d/default.conf && nginx -g ‘daemon off;'”


Docker hub –


Terraform vs Cloudformation


AWS solutions architect


  • Business logic in EC2, structured data in RDS and static content in S3





  • AWS associate
  • AWS professional – devops engineer and solutions architect



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at

Up ↑

%d bloggers like this: