{"id":18746085,"url":"https://github.com/fscm/docker-mongodb","last_synced_at":"2026-05-09T14:04:15.070Z","repository":{"id":202050233,"uuid":"172538992","full_name":"fscm/docker-mongodb","owner":"fscm","description":"Docker recipe to build an MongoDB image","archived":false,"fork":false,"pushed_at":"2022-01-03T15:58:54.000Z","size":36,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-28T20:27:05.180Z","etag":null,"topics":["docker","docker-image","dockerfile","mongodb"],"latest_commit_sha":null,"homepage":null,"language":"Dockerfile","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fscm.png","metadata":{"files":{"readme":"README.build.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-02-25T16:09:32.000Z","updated_at":"2024-04-02T14:48:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"12c869af-cb68-418b-8522-7b3912ec6f15","html_url":"https://github.com/fscm/docker-mongodb","commit_stats":null,"previous_names":["fscm/docker-mongodb"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fscm%2Fdocker-mongodb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fscm%2Fdocker-mongodb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fscm%2Fdocker-mongodb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fscm%2Fdocker-mongodb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fscm","download_url":"https://codeload.github.com/fscm/docker-mongodb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239627588,"owners_count":19670914,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-image","dockerfile","mongodb"],"created_at":"2024-11-07T16:20:51.096Z","updated_at":"2025-11-23T16:30:18.914Z","avatar_url":"https://github.com/fscm.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MongoDB for Docker\n\nDocker image with MongoDB.\n\n## Synopsis\n\nThis script will create a Docker image with MongoDB installed and with all\nof the required initialization scripts.\n\nThe Docker image resulting from this script should be the one used to\ninstantiate a MongoDB server.\n\n## Getting Started\n\nThere are a couple of things needed for the script to work.\n\n### Prerequisites\n\nDocker, either the Community Edition (CE) or Enterprise Edition (EE), needs to\nbe installed on your local computer.\n\n#### Docker\n\nDocker installation instructions can be found\n[here](https://docs.docker.com/install/).\n\n### Usage\n\nIn order to create a Docker image using this Dockerfile you need to run the\n`docker` command with a few options.\n\n```shell\ndocker image build --force-rm --no-cache --quiet --tag \u003cUSER\u003e/\u003cIMAGE\u003e:\u003cTAG\u003e \u003cPATH\u003e\n```\n\n- `\u003cUSER\u003e` - *[required]* The user that will own the container image (e.g.: \"johndoe\").\n- `\u003cIMAGE\u003e` - *[required]* The container name (e.g.: \"mongodb\").\n- `\u003cTAG\u003e` - *[required]* The container tag (e.g.: \"latest\").\n- `\u003cPATH\u003e` - *[required]* The location of the Dockerfile folder.\n\nA build example:\n\n```shell\ndocker image build --force-rm --no-cache --quiet --tag johndoe/my_mongodb:latest .\n```\n\nTo clean any _`none`_ image(s) left by the build process the following\ncommand can be used:\n\n```shell\ndocker image rm `docker image ls --filter \"dangling=true\" --quiet`\n```\n\nYou can also use the following command to achieve the same result:\n\n```shell\ndocker image prune -f\n```\n\n### Instantiate a Container\n\nIn order to end up with a functional MongoDB service - after having build\nthe container - some configurations have to be performed.\n\nTo help perform those configurations a small set of commands is included on the\nDocker container.\n\n- `help` - Usage help.\n- `init` - Configure the MongoDB service (__Not required in this image__).\n- `start` - Start the MongoDB service.\n\nTo store the data of the MongoDB server a volume should be created and added\nto the container when running the same.\n\n#### Creating Volumes\n\nTo be able to make all of the MongoDB data persistent, the same will have to\nbe stored on a different volume.\n\nCreating volumes can be done using the `docker` tool. To create a volume use\nthe following command:\n\n```shell\ndocker volume create --name \u003cVOLUME_NAME\u003e\n```\n\nTwo create the required volume the following command can be used:\n\n```shell\ndocker volume create --name my_mongodb\n```\n\n**Note:** A local folder can also be used instead of a volume. Use the path of\nthe folder in place of the volume name.\n\n#### Configuring the MongoDB Server\n\nThis step is not required for this MongoDB Docker image.\n\n#### Start the MongoDB Server\n\nAfter configuring the MongoDB server the same can now be started.\n\nStarting the MongoDB server can be done with the `start` command.\n\n```shell\ndocker container run --volume \u003cMONGODB_VOL\u003e:/data:rw --detach --publish 27017:27017 \u003cUSER\u003e/\u003cIMAGE\u003e:\u003cTAG\u003e start\n```\n\nTo help managing the container and the MongoDB instance a name can be given\nto the container. To do this use the `--name \u003cNAME\u003e` docker option when\nstarting the server\n\nAn example on how the MongoDB service can be started:\n\n```shell\ndocker container run --volume my_mongodb:/data/mongodb:rw --detach --publish 27017:27017 --name my_mongodb johndoe/my_mongodb:latest start\n```\n\nTo see the output of the container that was started use the following command:\n\n```shell\ndocker container attach \u003cCONTAINER_ID\u003e\n```\n\nUse the `ctrl+p` `ctrl+q` command sequence to detach from the container.\n\n#### Stop the MongoDB Server\n\nIf needed the MongoDB server can be stoped and later started again (as long as\nthe command used to perform the initial start was as indicated before).\n\nTo stop the server use the following command:\n\n```shell\ndocker container stop \u003cCONTAINER_ID\u003e\n```\n\nTo start the server again use the following command:\n\n```shell\ndocker container start \u003cCONTAINER_ID\u003e\n```\n\n### MongoDB Status\n\nThe MongoDB server status can be check by looking at the MongoDB server output\ndata using the docker command:\n\n```shell\ndocker container logs \u003cCONTAINER_ID\u003e\n```\n\n### Add Tags to the Docker Image\n\nAdditional tags can be added to the image using the following command:\n\n```shell\ndocker image tag \u003cimage_id\u003e \u003cuser\u003e/\u003cimage\u003e:\u003cextra_tag\u003e\n```\n\n### Push the image to Docker Hub\n\nAfter adding an image to Docker, that image can be pushed to a Docker registry... Like Docker Hub.\n\nMake sure that you are logged in to the service.\n\n```shell\ndocker login\n```\n\nWhen logged in, an image can be pushed using the following command:\n\n```shell\ndocker image push \u003cuser\u003e/\u003cimage\u003e:\u003ctag\u003e\n```\n\nExtra tags can also be pushed.\n\n```shell\ndocker image push \u003cuser\u003e/\u003cimage\u003e:\u003cextra_tag\u003e\n```\n\n## Contributing\n\n1. Fork it!\n2. Create your feature branch: `git checkout -b my-new-feature`\n3. Commit your changes: `git commit -am 'Add some feature'`\n4. Push to the branch: `git push origin my-new-feature`\n5. Submit a pull request\n\nPlease read the [CONTRIBUTING.md](CONTRIBUTING.md) file for more details on how\nto contribute to this project.\n\n## Versioning\n\nThis project uses [SemVer](http://semver.org/) for versioning. For the versions\navailable, see the [tags on this repository](https://github.com/fscm/docker-mongodb/tags).\n\n## Authors\n\n- **Frederico Martins** - [fscm](https://github.com/fscm)\n\nSee also the list of [contributors](https://github.com/fscm/docker-mongodb/contributors)\nwho participated in this project.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE)\nfile for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffscm%2Fdocker-mongodb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffscm%2Fdocker-mongodb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffscm%2Fdocker-mongodb/lists"}