In this post, I’ll explain how I containerised WordPress with custom themes and additional plugins as a Docker application and then deploy to AWS and ECS.

In this example, I’ve migrated the National Archives’ blog to Amazon Web Services. WordPress is the blogging platform, which is made stateless using Docker. Docker is a software platform to create, deploy and manage virtualised application containers on a common operating system.
I use Terraform to create the infrastructure in AWS, so it’s easy to track all the resources as code. ECS or Elastic Container Service is described by Amazon as a container orchestration service that supports Docker containers. For my example, ECS is used to run and scale the WordPress Docker application. To deploy the Docker container to ECS I’m using Packer and ECR, Elastic Container Registry.
Finally, with the use of a plugin, all the static media resources used by WordPress is delivered via CloudFront and S3 bucket (CDN).

AWS Infrastructure
I created a Terraform module, which stores the code that handles the creation of a group of resources needed for the WordPress infrastructure, and then applied it to existing development, test and production environments.
The module creates a ECS cluster, EC2s, ECR, IAM roles and policies, RDS (databases), Route 53 (internal DNS), and Security Groups.
Deploying the Docker container to ECR
I’m using Packer to create, tag and push the WordPress Docker image to ECR. To achieve a scalable image I’ve made the WordPress container stateless, meaning that no data is attached to the host the container is running on. Content is stored on an external database (RDS), media resources are stored in a S3 bucket and environment variables are past into the container at launch.
Packer grabs the latest WordPress image from Docker Hub and installs the desired plugins and themes. It also installs WP CLI. It then tags the image and pushes it to ECR, a repository where the ECS can access and launch the image.
ECS Cluster
ECS or Elastic Container Service is an AWS Service that handles the Docker containers orchestration in the EC2 cluster. When the ECS grabs the Docker image from the ECR and launches a new container into the cluster it uses a Task Definition. The Task Definition tells WordPress about the database, media S3 bucket, CDN URL and environment variables.
That’s it!
This is a brief explanation how I containerised WordPress as a stateless Docker application with themes and plugins and then deploy to AWS. Why do this? Here are a few reasons:
- Rapid design and development iterations via continuous integration
- Scalable and resilient architecture
- Enhanced security
- Faster content delivery