
如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
!logo
"Percona Server for MongoDB is a a source-available, fully compatible drop-in replacement for MongoDB Community Edition. It includes enterprise security, backup and developer-friendly features otherwise available only in the MongoDB EE.
Key features include:
For more information and related downloads for Percona Server and other Percona products, please visit [***]
Percona Server for MongoDB Docker images, created and maintained by the Percona team.
Images are updated when new releases are published.
Start a Percona Server for MongoDB container as follows:
docker run --name container-name -d percona/percona-server-mongodb:tag
Where container-name is the name you want to assign to your container and tag is the tag specifying the version you want. See the list above for relevant tags, or look at the https://hub.docker.com/r/percona/percona-server-mongodb/tags/.
Use the following command to get the access to the bash shell and run commands inside the Docker container:
docker exec -it container-name bash
where container-name is the name of your database container.
To access Percona Server for MongoDB from an application that is running locally, you need to expose the port using the -p option. The following example shows exposing the standard MongoDB port (27017)
docker run --name container-name -p 27017:27017 -d percona/percona-server-mongodb:tag
where container-name is the name of your database container.
Using this method, you will be able to connect to your MongoDB instance on mongodb://localhost:27017.
This image exposes the standard MongoDB port (27017), so container linking makes the instance available to other containers. Start other containers like this in order to link it to the Percona Server for MongoDB container:
docker run --name app-container-name --link container-name -d app-that-uses-mongodb
The following command starts another container instance and runs the mongo/ mongosh command line client against your original container, allowing you to execute commands against your database:
docker run -it --link psmdb --rm percona/percona-server-mongodb:tag mongo mongodb://MONGODB_SERVER:PORT/DB_NAME
For Percona Server for MongoDB 6.0+ and onwards, the mongosh command line client is used. To connect to it, run the command as follows
docker run -it --link psmdb --rm percona/percona-server-mongodb:6.0 mongosh mongodb://MONGODB_SERVER:PORT/DB_NAME
Set MONGODB_SERVER with the IP address of the psmdb container, PORT - with the port of your MongoDB Server (default value is 27017), and DB_NAME with the name of the database you want to connect to.
You can get the IP address by running this command:
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' psmdb
When you start the percona/percona-server-mongodb image, you can adjust the initialization of the MongoDB instance by passing one or more environment variables on the docker run command line. Note that none of the variables below will have any effect if you start the container with a data directory that already contains a database: any pre-existing database will always be left untouched on container startup.
MONGO_INITDB_ROOT_USERNAME, MONGO_INITDB_ROOT_PASSWORD
Using these variables in conjunction allows you to create a new user and set that user's password. This user is created in the admin authentication database and given the role of root.
The following is an example of using these two variables to create a MongoDB instance and then using the mongo CLI to connect against the admin authentication database.
$ docker run -d --name container-name \ -e MONGO_INITDB_ROOT_USERNAME=mongoadmin \ -e MONGO_INITDB_ROOT_PASSWORD=secret \ percona/percona-server-mongodb:tag $ docker exec -it container-name \ mongo -u mongoadmin \ -p secret \ --authenticationDatabase admin \ some-db > db.getName(); some-db
Both variables are required for a user to be created. If both are present, then MongoDB will start with authentication enabled (mongod --auth).
To read more about authentication in MongoDB, refer to this upstream documentation:
mongod --authAs an alternative to passing sensitive information via environment variables, _you can specify the variables and their values in an environment file and pass this file during the container start. For example:
docker run --name container-name --env-file path/to/mongo-env -d percona/percona-server-mongodb:tag
where container-name is the name of your database container and path/to/mongo-env is the path to the environment file on your local filesystem.
There are many two ways to store data used by applications that run in Docker containers. We maintain our usual stance and encourage users to investigate the options and use the method that best suits their use case. Here are some of the options available:
The Docker documentation is a good starting point for understanding the different storage options and variations, and there are multiple blog and forum postings that discuss and give advice in this area. We will simply show the basic procedure here for the latter option above:
/local/datadir.docker run --name container-name -v /local/datadir:/data/db -d percona/percona-server-mongodb:tag
The -v /local/datadir:/data/db part of the command mounts the /local/datadir directory from the underlying host system as /data/db inside the container, where MongoDB by default will write its data files.
The Percona Server for MongoDB Server log is available through Docker's container log:
$ docker logs container-name
where container-name is the name of your database container.
You can pass arbitrary command line options to the server by appending them to the run command:
docker run --name my-container-name -d percona/percona-server-mongodb --option1=value --option2=value
We welcome your feedback!
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务
以下是 percona/percona-server-mongodb 相关的常用 Docker 镜像,适用于 不同场景 等不同场景: