我使用以下容器定义在 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/