I have a centos container with a mongodb service installed and configured. When i start container manuallyl like this:
docker run -it image bash
after start i enter in container and start a mongo manually (/etc/init.d/mongodb start), the service works perfectly,
but when i start a service with container (docker run -it image /etc/init.d//mongodb startt) the container enter in “exited” mode and don’t start.
someone can help me??
Which Docker image is used? If the official MongoDB image “mongo” is used the command is
docker run --name mongodb -d mongo
I used official mongo image, but the service won’t start when i run “docker run” with start service parameter. For start a service, i need to enter in container and start service manually.
To run the service in the container, you shouldn’t need more than:
docker pull mongo
docker run -d -p 27017:27017 mongo
This will start the container with MongoDB running. You can verify this with a tool like Robo 3T (formerly Robomongo).
right, but this way how i restore a database in container for example and save ?
restore manually in container and commit?
i make this way and get the problem above
If you aren’t worried about saving the new version of your container, I would do the restore from a second container that is linked to the first:
docker run --link mymongod:db ... mongo mongorestore -h db ...
If you need a new version of the container as part of the restore process, I recommend researching some of the scripts available for doing backups and restores. I would either utilize one of them as-is or use them as a guide to write your own.
Right, i tried to make this way this week and post here my results.