11

i'm running my multi services architecture using Docker and aws Elastic Beanstalk. One of those services is a mongoDB Docker image. It's supposed to expose port 27017 so other services can connect to the mongo DB in that port. Unfortunately Elastic Beanstalk internal nginx only exposes port 80, so my services aren't able to connect to mongo DB on port 27017.

I've seen some answers (https://stackoverflow.com/a/24831425/1116959) around using some config files inside the /.ebextensions folder, but i don't know how to get this working with that workaround.

My architecture also includes a rabbitMQ service and other application services (python+celery). Does anyone know if it's better to start using Amazon VPC?

Any help is appreciated, thanks

0

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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" } 

1 Comment

Based on my experience this publishes the port 1234 through Nginx reverse proxy as port 80. As nginx by default supports only http, Mongodb wire protocol does not work as it requires TCP.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.