spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

How to setup a MongoDB with Vagrant and Docker


In order for servers to communicate I guess you would need to configure port forwarding properly, so that routing server would be able to access shards, and vice versa.

With Vagrant one can configure port forwarding, and in this case, I suppose also needs to be combined with ports being properly configured for Docker containers. Refer to Vagrant Networking Configuration page and Vagrant's Docker provider configuration page.

Worth noting that eventually you might also want to configure links between Docker containers, which is also done in Docker provider config. More about linking containers together is in Docker documentation.

Then, to add shards to the routing server, you might use Vagrant's Shell Provisioner. This one allows executing custom shell scripts on the machine once it is up and running. Provided that mongo client allows inline scripts to be run, you could use something similar to following:

app.vm.provision "shell", inline:
'mongo --eval "sh.addShard("shard1_host:port");"'

I'm sorry, I didn't test the command above myself, so not sure this will be working out of the box, but this gives a general idea. (In fact, I'm pretty sure there is something wrong with the quotes in it :) ).

You can also create variables in the Vagrantfile, just the same way as you would do in any other Ruby source file, and reuse them in order to not to repeat IPs and port numbers, for better maintainability.

Note that you can also run vagrant <name of the instnance> ssh to get the shell access into the container (provided it is in a 'running' state), and run commands inside. This might be useful when debugging the network and provisioning logic.

Excuse me, I didn't test any of these ideas with MongoDB exactly, but only with other types of services. But I think that same principles applied to MondoDB should work fine as well.


Categories : Mongodb

Related to : How to setup a MongoDB with Vagrant and Docker
Symfony 2 application on Vagrant + Docker
I haven't used vagrant with docker, but I have had a simliar issue just using vagrant and symfony. I had to configure the permissions for the logs and cache dirs in the vagrant file, so something like this (guest is Ubuntu 14.04): config.vm.synced_folder "symfony/app/cache", "/vagrant/symfony/app/cache", owner: "www-data", group: "vagrant", mount_options: ["dmode=775,fmode=664"] config.vm.synced

Categories : Symfony2
How to setup a small website using docker
The idiomatic way of using Docker is to try to keep to one process per container. So, Apache and MySQL etc should be in separate containers. You can then create a data-container to hold your website files and simply mount the volume in the Webserver container using --volumes-from. For more information see https://docs.docker.com/userguide/dockervolumes/, specifically "Creating and mounting a Data

Categories : Apache
How to use "setup.cfg" instead of setup.py with Python 2.7
The problem is that the setup.cfg file does not do what you want. It does not provide parameters to the setup function. It is used to supply parameters to the commands that setup.py makes available. You can list the supported commands with setup.py --help-commands. You should see something like: (env) gondolin/zender% ./setup.py --help-commands Standard commands: build build eve

Categories : Python
Why should i use vagrant if i use virtualenv?
The difference between virtualenv and Vagrant is that virtualenv is only about separate Python installations whereas Vagrant is about the whole machine. virtualenv isolates the Python interpreter and the Python dependencies on one machine so you can install multiple Python projects alongside each other with their own dependencies. But for the rest of the machine the virtualenv doesn't do anythin

Categories : Python
Setting up development vagrant box for Rails
you need to install the bundle gem using the rbenv gem command: rbenv global 2.1.2 # ensure all shims for current ruby version are there rbenv rehash gem install bundler # rehash again to make sure you get the `bundler` command from `rbenv` rbenv rehash bundle install Hope this helps

Categories : Ruby On Rails
Recently Add
python pymongo match not working
Where will MongoDB "forEach" commands run?
MongoDB tag range not working
MongoDB - make replica set member passive without disconnecting clients?
Is it possible to ensure uniqueness on a sharded hashed key in MongoDB?
Spring Data (mongoDb) + @Id element + EJB + DBRef. Cannot create a reference to an object with a NULL id
Mongo Db optimized query
how to set the data type of mongoexport
Meteor collection limit
MongoDB Query: How to add some days to a date field before comparing it with a given date
MongoDB elemMatch does not work expected
MongoDB: calculate average value for the document & then do the same thing across entire collection
cannot authenticate hashed password in Flask
How to replicate a Python 2.7, Bottle, MongoDB OpenShift application locally in Linux Mint 17?
Reactivemongo TTL collections
Accessing MongoDB from AppEngine app
SyntaxError: Unexpected token ILLEGAL. Please help me insert syntax
Why can't I aggregate with MongoDB with a $match?
Selecting MongoDB or DynamoDB pricing
MongoDB: How to count a field if it's value matches a condition?
failed login with correct credentials set in the admin db - MongoDb
PyMongo query on Aggregation
How can two keys be combined into one new object in Mongodb?
3 conditions with and does not work
How can I query mongodb for a list of credit cards that are about to expire?
Update all documents in a collection with random numbers
Cannot apply the positional operator without a corresponding query field containing an array
MongoDB - Update or Create an object in nested Array in Pymongo
MongoDB - Sorting a query twice?
How to define write preferences without tag sets?
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.