How to deploy mongoDB Docker image to Elastic Beanstalk? How to deploy mongoDB Docker image to Elastic Beanstalk? nginx nginx

How to deploy mongoDB Docker image to Elastic Beanstalk?


Now several months later, this is possible by using the Multicontainer Docker environment type: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_ecs.html.

Here's a proof-of-concept Dockerrun.aws.json which I have not yet used in production:

{  "AWSEBDockerrunVersion": 2,  "volumes": [    {      "name": "mongo-app",      "host": {        "sourcePath": "/var/app/current/mongo-app"      }    }  ],  "containerDefinitions": [    {      "name": "mongo-app",      "image": "mongo",      "essential": true,      "memory": 6000,      "command": ["mongod","--storageEngine=wiredTiger","--logpath=/var/log/mongodb/mongo.log"],    "portMappings": [        {          "hostPort": 27017,          "containerPort": 27017        }      ],      "mountPoints": [        {          "sourceVolume": "mongo-app",          "containerPath": "/data/db"        },        {          "sourceVolume": "awseb-logs-mongo-app",          "containerPath": "/var/log/mongodb"        }      ]    }  ]}

This approach requires that the environment type is set to Multicontainer Docker and that a security group is attached to Elastic Beanstalk environment that allows accessing port 27017 from database clients.


Dockerrun.aws.json has a whole section for ports. You could use that instead of the lower layer ebextensions config file.

{  "AWSEBDockerrunVersion": "1",  "Authentication": {    "Bucket": "my-bucket",    "Key": "mydockercfg"  },  "Image": {    "Name": "janedoe/image",    "Update": "true"  },  "Ports": [    {      "ContainerPort": "1234"    }  ],  "Volumes": [    {      "HostDirectory": "/var/app/mydb",      "ContainerDirectory": "/etc/mysql"    }  ],  "Logging": "/var/log/nginx"}