0

I pretty new with dockers and started to play with it during my last project. I have a MongoDB container which I wish to move between some machines during the development.

I have some questions regards it-

  1. Is there an option to copy-paste all the DB data? Mean that when I copy the image container I will be able to copy the DB's data as well? I tried to copy the related directory on my machine but it wasn't worked well (copying the host directory in -v host_directory:container_directory)

  2. Is there a way that I can create a Dockerfile that builds a mongo image and configures the DB? Such as set a new admin user, create DBs - so when I build the docker image all the settings and schemes will be the same?

Thanks ahead!

GMe
  • 1,091
  • 3
  • 13
  • 24
  • I think here are the answers you are looking for: 1. http://stackoverflow.com/a/20652410/4787945 2. http://stackoverflow.com/a/33601894/4787945 – martjanz May 19 '17 at 01:26
  • I had the same case so I created an sh script that builds a MongoDB cluster (docker run commands) and then via a series of docker exec commands I copy scripts that create users inside the containers and execute them (via docker exec). Finally, I also copy in the same way a previously created dump that contains all DBs and then restore it via mongorestore. – dchar May 19 '17 at 07:20

0 Answers0