我一直试图将Redash设置为在ECS上运行。一般来说,我对ECS和Docker还是比较陌生的,所以我不确定目前所做的工作是否缺少基本知识。
到目前为止,我已经将Redash's docker-compose file转换为AWS容器定义。
但是,根据Redash文档,我需要先运行docker-compose run --rm server create_db
才能在Postgres容器中设置表。
如何在ECS上下文中实现此docker-compose run
行为?
我注意到尝试通过在容器定义中添加一个setup-postgres
容器来强制这种行为是可行的,但这是不明智的选择。
[
{
"name": "postgres-setup",
"image": "redash/redash:latest",
"cpu": 100,
"memory": 150,
"links": [
"postgres",
"redis"
],
"command": [
"create_db"
],
"environment": [
{
"name": "PYTHONUNBUFFERED",
"value": "0"
},
{
"name": "REDASH_LOG_LEVEL",
"value": "INFO"
},
{
"name": "REDASH_REDIS_URL",
"value": "redis://redis:6379/0"
},
{
"name": "REDASH_DATABASE_URL",
"value": "postgresql://postgres@postgres/postgres"
},
{
"name": "REDASH_COOKIE_SECRET",
"value": "veryverysecret"
},
{
"name": "REDASH_WEB_WORKERS",
"value": "1"
}
],
"essential": false
},
{
"name": "nginx",
"image": "redash/nginx:latest",
"essential": false,
"cpu": 100,
"memory": 200,
"links": [
"server:redash"
],
"portMappings": [
{
"containerPort": 80,
"hostPort": 80
}
]
},
{
"name": "postgres",
"image": "postgres:9.5.6-alpine",
"essential": true,
"cpu": 100,
"memory": 300,
"mountPoints": [
{
"sourceVolume": "mytestvol",
"containerPath": "/var/lib/postgresql/data"
}
]
},
{
"name": "redis",
"image": "redis:3.0-alpine",
"essential": true,
"cpu": 100,
"memory": 400
},
{
"name": "server",
"image": "redash/redash:latest",
"cpu": 100,
"memory": 400,
"links": [
"postgres",
"redis"
],
"command": [
"server"
],
"environment": [
{
"name": "PYTHONUNBUFFERED",
"value": "0"
},
{
"name": "REDASH_LOG_LEVEL",
"value": "INFO"
},
{
"name": "REDASH_REDIS_URL",
"value": "redis://redis:6379/0"
},
{
"name": "REDASH_DATABASE_URL",
"value": "postgresql://postgres@postgres/postgres"
},
{
"name": "REDASH_COOKIE_SECRET",
"value": "veryverysecret"
},
{
"name": "REDASH_WEB_WORKERS",
"value": "1"
}
],
"essential": false,
"portMappings": [
{
"containerPort": 5000,
"hostPort": 5000
}
]
},
{
"name": "worker",
"image": "redash/redash:latest",
"cpu": 100,
"memory": 400,
"links": [
"postgres",
"redis"
],
"command": [
"scheduler"
],
"environment": [
{
"name": "PYTHONUNBUFFERED",
"value": "0"
},
{
"name": "REDASH_LOG_LEVEL",
"value": "INFO"
},
{
"name": "REDASH_REDIS_URL",
"value": "redis://redis:6379/0"
},
{
"name": "REDASH_DATABASE_URL",
"value": "postgresql://postgres@postgres/postgres"
},
{
"name": "QUEUES",
"value": "queries,scheduled_queries,celery"
},
{
"name": "WORKERS_COUNT",
"value": "1"
}
],
"essential": false
}
]
我知道在这样的容器中运行Postgres是不理想的,以后可能会将其移入RDS。如果我决定这样做,那么数据库初始化步骤将是什么样?创建ECS实例,下载docker-compose.yml
文件并运行docker-compose run --rm server create_db
进行一次性设置,然后再启动ECS服务?
答案 0 :(得分:0)
你没有。
您在这里看这两种错误的方式:
1)Docker Compose是开发工具,而不是生产工具。您可以在生产环境中使用撰写文件-但这将通过Docker Swarm使用,某些功能仅适用于docker-compose,而其他功能仅适用于Docker Swarm。
2)话虽如此-ECS是一个协调器,这就是Docker Swarm的本质(您想要的是什么)-因此,在ECS上运行Docker Swarm完全没有意义。
您要在此处创建的ECS任务定义已创建。这本质上是撰写文件的ECS版本。您可以设置映像,端口绑定,卷,容器链接等。
因此,您可以在此处选择是要在ECS中运行还是要设置Docker Swarm。
祝你好运!