简体   繁体   中英

Docker data-only container on AWS ECS

I have 4 docker containers where 2 keep running - nginx and hhvm. But furthermore I have 2 data-only containers that do not run permanently. That works quite fine unless you try to forward them to 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:

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.

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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