This documentation is for the end of life version of Percona Server for MongoDB and is no longer supported. You may want to see the current documentation.
Running Percona Server for MongoDB in a Docker Container¶
Docker images of Percona Server for MongoDB are hosted publicly on Docker Hub at https://hub.docker.com/r/percona/percona-server-mongodb/.
For more information about using Docker, see the Docker Docs.
Note
Make sure that you are using the latest version of Docker.  The ones provided
via apt and yum may be outdated and cause errors.
Note
By default, Docker will pull the image from Docker Hub if it is not available locally.
To run the latest Percona Server for MongoDB 4.0 in a Docker container, use the following command:
Run this command as root or by using the sudo command
$ docker run -d --name psmdb --restart always \
percona/percona-server-mongodb:4.0
The previous command does the following:
- The - docker runcommand instructs the- dockerdaemon to run a container from an image.
- The - -doption starts the container in detached mode (that is, in the background).
- The - --nameoption assigns a custom name for the container that you can use to reference the container within a Docker network. In this case:- psmdb.
- The - --restartoption defines the container’s restart policy. Setting it to- alwaysensures that the Docker daemon will start the container on startup and restart it if the container exits.
- percona/percona-server-mongodb:4.0is the name and version tag of the image to derive the container from.
See also
- Docker Documentation: the full list of tags
- https://hub.docker.com/r/percona/percona-server-mongodb/tags/ 
Connecting from Another Docker Container¶
The Percona Server for MongoDB container exposes standard MongoDB port (27017),
which can be used for connection from an application
running in another container.
To link the application container to the psmdb container,
use the --link psmdb option when running the container with your app.
Connecting with the Mongo Shell¶
To start another container with the mongo shell
that connects to your Percona Server for MongoDB container,
run the following comand: docker run -it --link psmdb --rm percona/percona-server-mongodb:mongo mongo -h psmdb