
manios/mongoBased on commit 7b2fe2c of official Mongo image version 3.0.15.
Dockerfile links2.6.0, 2.6, latest (2.6.0/Dockerfile) is a cross-platform document-oriented database. Classified as a NoSQL database, MongoDB eschews the traditional table-based relational database structure in favor of JSON-like documents with dynamic schemas (MongoDB calls the format BSON), making the integration of data in certain types of applications easier and faster. Released under a combination of the GNU Affero General Public License and the Apache License, MongoDB is free and open-source software.
First developed by the software company 10gen (now MongoDB Inc.) in October 2007 as a component of a planned platform as a service product, the company shifted to an open source development model in 2009, with 10gen offering commercial support and other services. Since then, MongoDB has been adopted as backend software by a number of major websites and services, including Craigslist, eBay, Foursquare, SourceForge, Viacom, and the New York Times, among others. MongoDB is the most popular NoSQL database system.
***.org/wiki/MongoDB
!logo
console$ docker run --name some-mongo -d manios/mongo
This image includes EXPOSE 27017 (the mongo port), so standard container linking will make it automatically available to the linked containers (as the following examples illustrate).
console$ docker run --name some-app --link some-mongo:manios/mongo -d application-that-uses-mongo
mongoconsole$ docker run -it --link some-mongo:mongo --rm manios/mongo sh -c 'exec mongo "$MONGO_PORT_27017_TCP_ADDR:$MONGO_PORT_27017_TCP_PORT/test"'
See the official docs for infomation on using and configuring MongoDB for things like replica sets and sharding.
Just add the --storageEngine argument if you want to use the WiredTiger storage engine in MongoDB 3.0 and above without making a config file. WiredTiger is the default storage engine in MongoDB 3.2 and above. Be sure to check the docs on how to upgrade from older versions.
console$ docker run --name some-mongo -d manios/mongo --storageEngine wiredTiger
MongoDB does not require authentication by default, but it can be configured to do so. For more details about the functionality described here, please see the sections in the official documentation which describe authentication and authorization in more detail.
console$ docker run --name some-mongo -d manios/mongo --auth
console$ docker exec -it some-mongo mongo admin connecting to: admin > db.createUser({ user: 'jsmith', pwd: 'some-initial-password', roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] }); Successfully added user: { "user" : "jsmith", "roles" : [ { "role" : "userAdminAnyDatabase", "db" : "admin" } ] }
console$ docker run -it --rm --link some-mongo:mongo manios/mongo mongo -u jsmith -p some-initial-password --authenticationDatabase admin some-mongo/some-db > db.getName(); some-db
Traditionally this image does output the logs to stdout. In order to write logs to a file use the following:
console$ docker run \ -d \ --name some-mongo \ -v /my/own/logdir:/data/log \ manios/mongo:2.6 --logpath /data/log/mongo.log \
The -v /my/own/logdir:/var/log/mongodb part of the command mounts the /my/own/logdir directory from the underlying host system as /var/log/mongodb inside the container, where MongoDB by default will write its log files.
By default docker has UTC as its timezone. If you want to have the same datetime as the host inside the container and show it properly in logs you can use the following:
console$ docker run \ -d \ --name some-mongo \ -v /my/own/logdir:/data/log \ -v /etc/localtime:/etc/localtime \ manios/mongo:2.6 --logpath /data/log/mongo.log \
The -v /etc/localtime:/etc/localtime part of the command mounts the /etc/localtime file from the underlying host system as :/etc/localtime inside the container. Thus MongoDB will display the date and time using the same timezone as the host in its log files.
Important note: There are several ways to store data used by applications that run in Docker containers. We encourage users of the mongo images to familiarize themselves with the options available, including:
WARNING (Windows & OS X): The default Docker setup on Windows and OS X uses a VirtualBox VM to host the Docker daemon. Unfortunately, the mechanism VirtualBox uses to share folders between the host system and the Docker container is not compatible with the memory mapped files used by MongoDB (see vbox bug, docs.mongodb.org and related jira.mongodb.org bug). This means that it is not possible to run a MongoDB container with the data directory mapped to the host.
The Docker documentation is a good starting point for understanding the different storage options and variations, and there are multiple blogs and forum postings that discuss and give advice in this area. We will simply show the basic procedure here for the latter option above:
Create a data directory on a suitable volume on your host system, e.g. /my/own/datadir.
Start your mongo container like this:
console$ docker run --name some-mongo -v /my/own/datadir:/data/db -d manios/mongo:tag
The -v /my/own/datadir:/data/db part of the command mounts the /my/own/datadir directory from the underlying host system as /data/db inside the container, where MongoDB by default will write its data files.
This image also defines a volume for /data/configdb for use with --configsvr (see docs.mongodb.com for more details).
Note that users on host systems with SELinux enabled may see issues with this. The current workaround is to assign the relevant SELinux policy type to the new data directory so that the container will be allowed to access it:
console$ chcon -Rt svirt_sandbox_file_t /my/own/datadir
mongo:<version>This is the defacto image. If you are unsure about what your needs are, you probably want to use this one. It is designed to be used both as a throw away container (mount your source code and start the container to start your app), as well as the base to build other images off of.


探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
无需登录使用专属域名
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
Harbor Proxy Repository 对接专属域名
Portainer Registries 加速拉取
Nexus3 Docker Proxy 内网缓存
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
manifest unknown
no matching manifest(架构)
invalid tar header(解压)
TLS 证书失败
DNS 超时
410 Gone 排查
402 与流量用尽
401 认证失败
429 限流
D-Bus 凭证提示
413 与超大单层
来自真实用户的反馈,见证轩辕镜像的优质服务