how to attach a EBS volume to my container using docker-compose.yml and ecs-cli

I am using docker-compose.yml to define a set of containers. And use ecs-cli compose (service) up to create my application on AWS.

I know AWS ECS comes with 100GB EBS automatically when a container is created. (Even though the EC2 instance that hosts the container only have 8GB of hard drive.)
I want to have a persistent storage so that even if I updated my container, it can still point to the same 100GB EBS. I am pretty sure I can do the following to achieve this goal:

  • How to keep a certain number of Docker containers running the same application and add/remove them as needed?
  • Unable to connect to docker daemon on Azure Windows Server 2016 machine through VSTS2017
  • cloudera manager can only inspect one host at a time
  • Why does Docker not correctly expose my port when using -P but works with -p 80:80?
  • Docker CentOS image does not auto start httpd
  • Does Docker install and run dependencies only when I'm using it?
  • Attach an external EBS to the EC2 instance, and use volume in the
    compose file to attach that volume to the container.

    However, I feel there might be a better way to do so on ECS since it gives you 100GB ELB automatically. That is, if I use the above approach, then I am really ‘wasting’ the 100GB volume that comes with each container.
    So, what is the best way to achieve this. Could you give an answer in the form of a docker-compose.yml format like the following?

      image: image1
      image: image2
        - "container1"

  • Building a docker image (.NET Core) and uploading it to Google Container Engine?
  • Passing reports through docker in codecov gives error
  • Can't connect Ngxin reverse proxy to Gunicorn on Django container (Docker)
  • Connecting local cassandra cluster with docker container
  • OSX terminal vs Docker CLI
  • docker compose, swarm and ip address inside dockerfile
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.