Skip to content
logo
Percona Server for MongoDB 6.0
Run Percona Server for MongoDB in a Docker container
Initializing search
    percona/psmdb-docs
    percona/psmdb-docs
    • Home
    • Percona Server for MongoDB feature comparison
      • System requirements
      • Install Percona Server for MongoDB on Debian and Ubuntu
      • Install Percona Server for MongoDB on Red Hat Enterprise Linux and derivatives
      • Install Percona Server for MongoDB from binary tarball
      • Run Percona Server for MongoDB in a Docker container
        • Connecting from another Docker container
        • Connecting with the mongosh shell
        • Percona Memory Engine
        • Hot Backup
        • $backupCursor and $backupCursorExtend aggregation stages
        • Authentication overview
        • Enable SCRAM authentication
        • Set up LDAP authentication with SASL
        • Set up x.509 authentication and LDAP authorization
        • Setting up Kerberos authentication
        • AWS IAM authentication
        • Setting up AWS IAM authentication
        • LDAP authorization
        • Set up LDAP authentication and authorization using NativeLDAP
        • Data at rest encryption
        • HashiCorp Vault integration
        • Using the Key Management Interoperability Protocol (KMIP)
        • Local key management using a keyfile
        • Migrate from key file encryption to HashiCorp Vault encryption
      • Auditing
      • Profiling rate limit
      • Log redaction
      • Additional text search algorithm - ngram
      • Tune parameters
        • Upgrade from 5.0 to 6.0
        • Upgrade Percona Server for MongoDB
      • Uninstall Percona Server for MongoDB
      • Release notes index
      • Percona Server for MongoDB 6.0.5-4 (2023-03-29)
      • Percona Server for MongoDB 6.0.4-3 (2023-01-30)
      • Percona Server for MongoDB 6.0.3-2 (2022-12-07)
      • Percona Server for MongoDB 6.0.2-1 (2022-10-31)
    • Glossary
    • Copyright and licensing information
    • Trademark policy

    • Connecting from another Docker container
    • Connecting with the mongosh shell

    Run Percona Server for MongoDB in a Docker container¶

    Docker images of Percona Server for MongoDB are hosted publicly on Docker Hub.

    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.

    By default, Docker will pull the image from Docker Hub if it is not available locally.

    To run the latest Percona Server for MongoDB 6.0 in a Docker container, run the following command as the root user or via sudo:

    $ docker run -d --name psmdb --restart always \
    percona/percona-server-mongodb:6.0
    
    $ docker run -d --name psmdb --restart always \
    percona/percona-server-mongodb:<TAG>-arm64
    

    Replace the <TAG> with the desired version (for example, 6.0.4-3-arm64)

    The command does the following:

    • The docker run command instructs the docker daemon to run a container from an image.

    • The -d option starts the container in detached mode (that is, in the background).

    • The --name option assigns a custom name for the container that you can use to reference the container within a Docker network. In this case: psmdb.

    • The --restart option defines the container’s restart policy. Setting it to always ensures that the Docker daemon will start the container on startup and restart it if the container exits.

    • percona/percona-server-mongodb:6.0 / percona/percona-server-mongodb:<TAG>-arm64 is the name and version tag of the image to derive the container from.

    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 mongosh shell¶

    To start another container with the mongosh shell that connects to your Percona Server for MongoDB container, run the following command:

    $ docker run -it --link psmdb --rm percona/percona-server-mongodb:6.0 mongosh mongodb://MONGODB_SERVER:PORT/DB_NAME
    

    Set MONGODB_SERVER, PORT, and DB_NAME with the IP address of the psmdb container, the port of your MongoDB Server (default value is 27017), and 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
    

    Contact Us

    For free technical help, visit the Percona Community Forum.

    To report bugs or submit feature requests, open a JIRA ticket.

    For paid support and managed or consulting services , contact Percona Sales.


    Last update: January 30, 2023
    Created: December 7, 2022
    Percona LLC and/or its affiliates, © 2023
    Made with Material for MkDocs

    Cookie consent

    We use cookies to recognize your repeated visits and preferences, as well as to measure the effectiveness of our documentation and whether users find what they're searching for. With your consent, you're helping us to make our documentation better.