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




WordPress 新手教學

  1. 發表文章與管理文章
  2. 選單
  3. 全部內容


  1. 只用文章發表 每篇文章必須分類
  2. 文章名稱使用中文
  3. 文章位址(URL) 使用英文
  5. 全部使用開源/免費外掛和佈景主題

site functions

  1. reference to other sites ( agoda, airbnb)
  2. move all media on google drive to ‘google photos’ and videos to youtube so that site can source from it.
  3. logo location
  4. link to social media
    1. facebook feed
    2. facebook like button
    3. facebook page – call to action button
    4. sign in to facebook
    5. link wordpress comment to facebook comment and the other way around
    6. pinterest and instagram
  5. online booking
    1. availability check for online reservation
    2. online payment 易付寶
  6. web: amp page
  7. plugins
    1. use contact form 7 for online form submission
      1. signature
      2. probably sent it to facebook messenger instead of gmail
    2. google translate/dictionary completed
    3. google map
    4. plugin auto optimize
    5. plugin hyper cache and wp cache
    6. plugin site statistics
    7. plugin jetpack

social media

  1. instagram, pinterest, facebook, twitter and other popular one in taiwan
  2. a lot of photos

twenty-seventeen theme – header media sizing


twenty-seventeen theme use slider as header media

  2. ensure you set a page as static front page

twenty-seventeen header video no sound

  1. workaround

About twenty-seventeen theme

  1. how to customize
  2. 5 ways to hack
  3. how to master it

Journal and Progress

  1. fine tune twenty-seventeen
  2. create categories
  3. create contact us page
  4. create main menu


Blog at

Up ↑