How to connect mongodb in contanier - mongodb

I deploy a mongodb in a container. and I also successfully connected to mongodb when my backend runs in the local environment. However, when I tried to move the backend to a container as well, it cannot connect mongodb anymore. The connection string remains the same but it failed.
The error shows that mongodb cannot find the user. However, in my local environment, the same connection string works.
After my googling, most guys said I need to change authSource. I have tried to change authSource to admin, it doesn't work even in my local environment. And I am sure the user exists in my admin database. not in api_dev_db. One wired thing is I can connect to mongodb in my local environment but not work in docker.
Could you kindly help me out?
Here I post some pictures.
These are the env variables I defined in my local environment and they work
This is how I deploy backend service
This is my backend dockerfile
This is the error when I deploy backend in container
This is how I initial mongodb

The problem is I need to remove '' in env variable, which is MONGO_URL=mongodb://api_user:api1234#mongodb:27017/api_dev_db?authSource=api_dev_db

Related

show dbs command only listing admin, local, config

i am new to mongodb environment working on a project front end, i need to setup the test database created by backend team on my local machine.
I installed the mongod and copied the files given by my team into c:/data/db and started the db with mongod command. I was able to run loopback api on localhost fine for the first time with all the project data.
Suddenly today when I try to use the same local api server (after starting mongo),it was showing the collections but there is not data inside the collections. When i did 'show dbs' command, it is only showing config, admin and local with each 0.00GB size.
Can anyone help me how to fix it and where i was going wrong.
Any help would be greatly appreciated. Thanks in advance.

Setting up Heroku with mongodb without using MLAB

Most of the documentation Ive seen only covers using mLab as a service for mongodb on heroku,
I would like to use mongoDB locally on the heroku server is this possible?
Heroku dynos use an ephemeral filesystem. This means that you cannot run a database on a Heroku dyno. All of the data will be lost whenever your process restarts. Your process restarts at least once every day, whenever you deploy new code, whenever you change config variables, or whenever you update add-ons.
You can read more about Heroku's ephemeral filesystem here: https://devcenter.heroku.com/articles/dynos#ephemeral-filesystem
You can read more about dyno restarts here: https://devcenter.heroku.com/articles/dynos#restarting
So you will have to use a Heroku Add-on or a third-party service to add persistence to your application.
This doesn't mean you have to use the mLab Add-on. If you have your own MongoDB database, you can still connect to that in your application. You can add the connection string as a config variable and connect to it in the same way you would connect to an mLab Add-on.

Using Docker and MongoDB

I have been using Docker and Kubernetes for a while now, and have set up a few databases(postgres and mysql) and services.
Now I was looking at adding a mongoDB, but it seems different when it comes to user management.
Take for example postgres:
https://hub.docker.com/_/postgres/
Immediately I can declare users with a password on setup and then connect using this. It seems the mongo image does not support this. Is there a way to simply declare users on startup and use them similar to the postgres setup? This is, without having to exec into the image, modify auth settings and restarting the mongo service.

ideal vm setup for meteor with shared folder

situation
Hello, I run arch Linux for which there is no meteor package and have an Ubuntu server run within virtualbox for web development. There is a shared folder I mount through database. hich means I can code in to the active environment.
However, like many others, I have a problem with mongodb starting up, specifically the exit code 100.
tracing the problem:
I created the /data/DB directory
gave access rights to my user
ran mongod on its own with no problems
Still I have the issue though.
Question
Where is the configuration file for mongodb which is installed with meteor so I can move it and do I need to create rights for a 'mongodb' user?
Question
What would be the ideal virtual machine for running a meteor development environment in the above set up? Having to create the data directory in the first place tells me Ubuntu server isn't ideal. some extra documentation available to answer this second question appearing on the meteor website would be beautiful
MongoDB does not work correctly on virtualbox shared folders. By default, meteor creates a mongo database in your project's directory, however you can override this behavior with the MONGO_URL environment variable. If you set this variable, meteor will not try to start mongo and will instead connect directly to the mongo endpoint you specify. This allows you to setup mongo however you like (eg using the Ubuntu mongodb package), with data somewhere not in the shared folder.

Logging into Mongo on Amazon's EC2 (AWS) with MongoVUE

This question is specific to MongoVUE, but really I am looking to be able to log in to Mongo on EC2 in any way besides through the SSH tunnel. I can do that and get a server and client up and running, create documents, find things etc. I am new to mongo and ec2 so I will admit there are a lot of variables.
Here is what I've done so far:
I have created a unique database and then added a user to that with the db.addUser('name','password') command.
I am using the public dns that AWS provided which looks like, xxxx.us-west-1.compute.amazonaws.com
I have tried to log in with the plain text password as well as the one mongo displays (hashed).
My ultimate goal is to be able to connect through C#, but MongoVue gives me an easier platform to fiddle around with (I hope).
Any help would be great! Thank you.
I was trying to do the same thing and it actually ended up being pretty easy after following the instructions on Mongovue's Blog
http://www.mongovue.com/2011/08/04/mongovue-connection-to-remote-server-over-ssh/
This allows you to not have to open up the MongoDB port externally also.
Make sure you also convert your EC2 .pem key to a Putty Key via PuttyGen first.
Okay, I solved it for those of you that will find this question and be in the same boat. For some reason I could not change my security group on ec2 to the one I had given access to port 27017. So I added that port exception to the security group that was currently assigned to my instance.
I then had to log in through SSH to get the Mongo server up and running (simply run the mongod command in the bin directory) and then it logged right in. I used the username and password that I had set up earlier through the mongo command line.
I hope this helps someone.