How do you share volumes between Docker containers in Elastic Beanstalk?

I am trying to exchange data between two Docker containers that run on an AWS EC2 multi- container instance.

I usually indicated how the command flag was when I started the container, i.e. docker run -p 80:80 -p 443:443 --link Widget:Widget --volumes-from Widget --name Nginx1 -d nginx1to share the volume with widgets on Nginx1.

However, since Elastic Beanstalk requires you to specify your Docker configuration in a file dockerrun.aws.jsonand then process the internal docker containers internally, I have not been able to figure out how to exchange data volumes between containers.

Please note that I am not trying to exchange data with an EC2 instance in a Docker container . This part is working fine; rather, I would like to share data directly from one Docker container to another. I know that docker container volumes are shared with host in "/var/lib/docker/volumes/fac362...80535", etc., but since this location is not static, I don’t know how I would refer to it in the file dockerrun.aws.json.

Has anyone found a solution or workaround?

For more information on dockerrun.aws.jsonand config EB, look here: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_v2config.html

Thank!

+4
source share
2 answers

, , volumesFrom. , VOLUME , .

Dockerfile, -:

FROM tianon/true
COPY build/ /opt/static
VOLUME ["/opt/static"]

Dockerrun.aws.json:

{
    "name": "staticfiles",
    "image": "mystaticcontainer",
    "essential": false,
    "memory": "16"
},
{
    "name": "webserver,
    ...
    "volumesFrom" : [
        {
            "sourceContainer": "staticfiles"
        }
    ]
}

, volumes Dockerrun.aws.json, . - mountPoints , , volumesFrom . /opt/static staticfiles webserver .

+5

AWS :

, volumeFrom ( ), sourceContainer .

volumeFrom , , Docker.

+2

All Articles