
!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 镜像,适用于 不同场景 等不同场景:
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。





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