amazon-web-services - 适用于 Wordpress 的 AWS ECS 服务

标签 amazon-web-services docker amazon-ec2 docker-compose amazon-ecs

我使用以下容器定义在 AWS ECS 上为 wordpress 创建了一个服务

{
  "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"
}

然后转到公共(public)IP并完成Wordpress安装。我还添加了一些帖子。

但是现在,当我更新服务以使用更新的任务定义(更新的 mysql 容器镜像)
"image": "mysql:latest"

我丢失了所有创建的帖子和数据,Wordpress 提示我再次安装。

我究竟做错了什么?

我也尝试使用主机卷,但没有成功 - 创建一个绑定(bind)挂载和一个 docker 管理卷(是否对容器进行了 docker 检查)。

因此,每次我更新任务时,它都会重置 Wordpress。

最佳答案

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

关于amazon-web-services - 适用于 Wordpress 的 AWS ECS 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49509902/

相关文章:

amazon-web-services - Cloudwatch 指标的移动平均线和趋势

amazon-web-services - 带有 Lambda 代理的 AWS API Gateway 总是产生 base64 字符串响应

node.js - 检查 dynamodb 中现有的主键

java - 我如何等待 Java 应用程序中的 Elastic MapReduce 作业流完成?

docker -/bin/sh : app: not found

docker-compose 在另一个目录中运行入口点脚本

Python Boto 创建的 cloud-init #include 脚本未在 EC2 上运行

database - 在亚马逊 ec2 上运行 perl 脚本

amazon-web-services - 确定性地创建和标记 EC2 实例

docker - 如何远程连接到 docker swarm?