How to add seeded data into the mongodb using docker? - mongodb

I have a mongo-seed image and mongo image set up
How can i run the mongo database up with the seeded data in docker.

use docker link in-order to link 2 dependent containers
It explained here , it might helpfull
https://rominirani.com/docker-tutorial-series-part-8-linking-containers-69a4e5bf50fb
If your using docker-compose then here is the solution which you looking
https://gist.github.com/jschwarty/6f9907e2871d1ece5bde53d259c18d5f

Related

Create Read-Only MongoDB container read data of the existing MongoDB container

I have running MongoDB as Docker container. Now I want to create one more MongoDB container but read-only and read data from the existing one.
What should I do? I don't use Docker Swarm mode!
I want to have 2 MongoDB container run, the existing is keep running, the new one is read-only and read data from the existing container.
Thanks for reading!

Share MongoDB across 2 Docker containers having different MongoDB versions

Already a fully-fledged mongo v3.2 instance with data is running on a container.
I need to create a mongo v3.6 container instance with the same data as v3.2.
I do not have space to clone the data on the server.
I tried a lot of stuff.
Can I point to the data of the v3.2 from my v3.6 so that it is shared and I save space?
You can try this. Don't know if it would work(because of different versions of mongodb).
You can create a sharded cluster and add your old DB as a shard.
I got the space cleared.
Got the dump and made a new instance of mongo.
It works like a charm now.
The sharing volume was corrupting the data.

Docker postgres how to share database

I'm running a PostgreSQL db via docker postgres.
I have populated the db with lots of data and would like to share it with others.
Is there a way to 'save' this database with all the data as a new image and publish it to a Docker registry so it can be easily pulled and used?
You can use docker container commit https://docs.docker.com/engine/reference/commandline/commit/ to create an image from a container.
Then you can publish that image to a docker registry for use by others.

How MongoDB works with Docker

a quick question about how docker and mongo coexist.
When I deploy my app to docker hub, does it include db records?
When docker removes mongo records. When I stop container, or only when I remove it?
The answer is depends...
You could create a image with your records, but that would increase your image size, and if someone mount a volume to the path /data/db they would lose your database. So I do not recommend to upload a image with a loaded database, instead use a custom entrypoint script to init your database.
About when the records are destroyed, it will happen when you remove the container, but only if you did not mount a volume to the folder /data/db in the container, then the database will be persisted even if you remove the container.
You can see more info about how to use the image at: https://hub.docker.com/_/mongo/

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.