简体   繁体   English

AWS ECS 上的 Docker 纯数据容器

[英]Docker data-only container on AWS ECS

I have 4 docker containers where 2 keep running - nginx and hhvm.我有 4 个 docker 容器,其中 2 个继续运行 - nginx 和 hhvm。 But furthermore I have 2 data-only containers that do not run permanently.但此外,我有 2 个不能永久运行的纯数据容器。 That works quite fine unless you try to forward them to AWS ECS.除非您尝试将它们转发到 AWS ECS,否则效果很好。

09c4fc12-b63a-48a9-baba-ebcb67191cf0/data   STOPPED ExitCode: 0         ecscompose-docker:9
09c4fc12-b63a-48a9-baba-ebcb67191cf0/hhvm   STOPPED                     ecscompose-docker:9
09c4fc12-b63a-48a9-baba-ebcb67191cf0/nginx  STOPPED                     ecscompose-docker:9
09c4fc12-b63a-48a9-baba-ebcb67191cf0/data2  STOPPED ExitCode: 0         ecscompose-docker:9

In general data-only containers only have to exist but do not have to keep running.一般来说,纯数据容器只需要存在,但不必一直运行。 So I am not sure what to face now.所以我不知道现在要面对什么。 Keep the containers running would be just a hotfix but not a solution.保持容器运行只是一个修补程序,而不是解决方案。

Since data-only containers are not the best solution because it is treated like garbage when deploying it - I thought about using some other persistent stores that could be referred.由于仅数据容器不是最佳解决方案,因为它在部署时被视为垃圾 - 我考虑使用其他一些可以引用的持久存储。 But I am not sure about this.但我不确定这一点。

It is kind of hacky, but an AWS tech suggested I put this at the bottom of my Dockerfile:这有点 hacky,但 AWS 技术人员建议我将其放在 Dockerfile 的底部:

CMD ["/bin/sh", "-c", "while true; do sleep 1; done"]

That will keep your data-only volume container running so that ECS will be happy.这将使您的仅数据卷容器保持运行,以便 ECS 感到满意。

I am assuming the data container formats data and generates an output which is consumed by other containers.我假设数据容器格式化数据并生成由其他容器使用的输出。

If docker links have been defined between data and the other containers, you will have to run both the containers.如果已在数据和其他容器之间定义了 docker 链接,则您必须同时运行这两个容器。

If the data containers are only temporary, I would suggest defining a docker data volume for the data container and write data into the volume.如果数据容器只是临时的,我建议为数据容器定义一个 docker 数据卷并将数据写入该卷。

A data volume is backed by directory from Engine daemon's host, the same location can then be loaded as volume into other containers which can use the data available at the location.数据卷由引擎守护程序主机的目录支持,然后可以将同一位置作为卷加载到其他容器中,这些容器可以使用该位置可用的数据。

When defining the volume, make sure you can assign appropriate RW permissions based on the container functionality.定义卷时,请确保您可以根据容器功能分配适当的 RW 权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM