Deploy a WordPress Blog in AWS with Docker (DevOps/Cloud Automation — Part IV)

Iyana Garry
4 min readMar 28, 2019

This tutorial will focus on deploying a live site to AWS with a Docker Compose file.

Docker is software that runs web applications on what are called containers. Containers are more lightweight than virtual machines because they all run on one operating system kernel.

Docker Compose is a tool that runs web applications on more than one container.

  1. Install the AWS command line interface.

If you’ve been following this tutorial series while using RHEL 7, then you know the drill.

2. Install the ECS CLI.

This tutorial will be different from the others.
We will not be installing Docker, but a separate AWS CLI for their Docker-like service, ECS (Elastic Container Service.)

The software will be downloaded in the ‘/usr/local/bin’ directory under the name ‘ecs-cli’, so the terminal will recognize the ‘ecs-cli’ commands we will be running.

3. Configure the ECS CLI.

The ECS CLI needs the AWS access key, secret key and a name for the ECS cluster and configuration (the cluster and configuration can have the same name) and a name for your AWS profile.

Note: The configuration name can only be alphanumeric, with an optional ‘-’ character.

4. Create an SSH key pair.

You need an SSH key to connect to the EC2 instance locally.

5. Create a cluster in ECS.

ECS’ command line interface needs to be configured with the SSH key pair, the size of the 2 instances (yes, 2) and a name for the cluster that will be created in ECS.

Another difference between this tutorial and the other tutorials, is that the 2 EC2 instances will be created with the t2.medium size instead of the t2.micro size. The t2.micro-sized instances will not have enough RAM for the ECS cluster.

Note: I entered this command with the ‘ --force’ parameter because I received an error; I forgot to create the SSH key before the cluster. However, the cluster was still created, so the ‘--force’ parameter overwrites the cluster.

6. Create a Docker Compose file.

This file contains parameters that will deploy the WordPress and MySQL software, using the specified hardware requirements needed (100 CPU units and 500 MB of RAM), and the log configurations.

The file must be named ‘docker-compose.yml’ in order for ECS to deploy the file.

7. Deploy the Docker Compose file to the ECS cluster.

The terminal needs to be in the same directory as the Docker Compose file so the ECS CLI will find it and deploy it.

8. View the containers on the cluster.

This command will display the status of the ECS cluster. In the command output, you should see the public IP address of the WordPress blog. Copy and paste the URL to the URL bar of your browser and you will be redirected to the blog’s admin page.

View Part I of this tutorial series on WordPress blog deployment with Terraform.

View Part II of this tutorial series on WordPress blog deployment with Chef.

View Part III of this tutorial series on WordPress blog deployment with Ansible.

--

--