0
votes

I created a service for wordpress on AWS ECS with the following container definitions

{
  "containerDefinitions": [
    {
      "name": "wordpress",
      "links": [
        "mysql"
      ],
      "image": "wordpress",
      "essential": true,
      "portMappings": [
        {
          "containerPort": 0,
          "hostPort": 80
        }
      ],
      "memory": 250,
      "cpu": 10
    },
    {
      "environment": [
        {
          "name": "MYSQL_ROOT_PASSWORD",
          "value": "password"
        }
      ],
      "name": "mysql",
      "image": "mysql",
      "cpu": 10,
      "memory": 250,
      "essential": true
    }
  ],
  "family": "wordpress"
}

Then went over to the public IP and completed the Wordpress installation. I also added a few posts.

But now, when I update the service to use a an updated task definition (Updated mysql container image)

"image": "mysql:latest"

I loose all the posts created and data and Wordpress prompts me to install again.

What am i doing wrong?

I also tried to use host volumes but to no vail - creates a bind mount and a docker managed volume (Did a docker inspect on container).

So, every time I update the task it resets Wordpress.

1

1 Answers

4
votes

If your container needs access to the original data each time it starts, you require a file system that your containers can connect to regardless of which instance they’re running on. That’s where EFS comes in.

EFS allows you to persist data onto a durable shared file system that all of the ECS container instances in the ECS cluster can use.

Step-by-step Instructions to Setup an AWS ECS Cluster

Using Data Volumes in Tasks

Using Amazon EFS to Persist Data from Amazon ECS Containers