In deploying a multicontainer Docker application to Elastic Beanstalk I needed to mount a volume from one container into another. Something similar to:
docker run --volumes-from my-data-container my-container
I got a little stuck because the docs for running a multicontainer application in Beanstalk talk about mounting volumes on the host but not between containers. The solution is to look at the documentation for ECS itself. Which makes sense since that’s what Beanstalk is using under the covers.
One note on the ECS documentation is that you do not need a “volumes” section nor do you need to define the exported volumes in your data container. Doing so will wipe out the data in your data volume. Simply the following is enough:
"containerDefinitions": [ { "name": "app-container", "image": "my-app:latest", "essential": true, "memory": 128, "volumesFrom": [ { "sourceContainer" : "my-app-data" } ], "portMappings": [ { "hostPort": 80, "containerPort": 80 } ] }, { "name": "my-app-data", "image": "my-app-data:latest", "essential": false, "memory": 128 } ]
Hope this helps!