Database Manual / Self-Managed Deployments / Installation / Enterprise

Install MongoDB Enterprise with Docker

Warning

MongoDB 8.3 Not Yet Available

MongoDB 8.3 release candidates are not yet available. This version of the manual is for an upcoming release and is currently a work in progress.

Important

MongoDB 8.3 is the latest minor release. Starting with MongoDB 8.2, minor releases are available for on-premises deployments (Community and EA) for specific use cases. For more information, see MongoDB Versioning.

To install the latest MongoDB version supported for on-premises use, see the installation instructions.

Important

The recommended solutions for using containers with MongoDB are:

You can run MongoDB Enterprise Edition as a Docker container using the official MongoDB Enterprise image. Use a Docker container to run your MongoDB deployment if you want to:

About This Task

  • This page assumes prior knowledge of Docker. A full description of Docker is beyond the scope of this documentation.
  • This procedure uses the official MongoDB Enterprise Advanced Server container, which is maintained by MongoDB.
  • MongoDB 5.0+ Docker images require AVX support on your system. If your system does not support AVX, you can use a docker image of MongoDB prior to version 5.0.

    Warning

    Versions of MongoDB prior to 6.0 are EOL'd and no longer supported by MongoDB. These versions should be used for testing purposes only.

Before You Begin

Steps

1

Pull the MongoDB Docker Image

docker pull mongodb/mongodb-enterprise-server:latest
2

Run the Image as a Container

docker run --name mongodb -p 27017:27017 -d mongodb/mongodb-enterprise-server:latest

The -p 27017:27017 in this command maps the container port to the host port. This allows you to connect to MongoDB with a localhost:27017 connection string.

To install a specific version of MongoDB, specify the version after the : in the Docker run command. Docker pulls and runs the specified version.

For example, to run MongoDB 5.0:

docker run --name mongodb -p 27017:27017 -d mongodb/mongodb-enterprise-server:5.0-ubuntu2004

For a full list of available versions, see Tags.

Note

Add Command Line Options

You can use mongod command-line options by appending the command-line options to the docker run command.

For example, consider the mongod --replSet docker command-line option:

docker run -p 27017:27017 -d mongodb/mongodb-enterprise-server:latest --name mongodb --replSet myReplicaSet
3

Check that the Container is Running

To check the status of your Docker container, run the following command:

docker container ls

The output from the ls command lists the following fields that describe the running container:

  • Container ID
  • Image
  • Command
  • Created
  • Status
  • Port
  • Names
CONTAINER ID   IMAGE                                      COMMAND                 CREATED         STATUS         PORTS       NAMES
c29db5687290 mongodb-enterprise-server:latest "docker-entrypoint.s…" 4 seconds ago Up 3 seconds 27017/tcp mongo
4

Connect to the MongoDB Deployment with mongosh

mongosh --port 27017
5

Validate Your Deployment

To confirm your MongoDB instance is running, run the Hello command:

db.runCommand(
{
hello: 1
}
)

The result of this command returns a document describing your mongod deployment:

{
isWritablePrimary: true,
topologyVersion: {
processId: ObjectId("63c00e27195285e827d48908"),
counter: Long("0")
},
maxBsonObjectSize: 16777216,
maxMessageSizeBytes: 48000000,
maxWriteBatchSize: 100000,
localTime: ISODate("2023-01-12T16:51:10.132Z"),
logicalSessionTimeoutMinutes: 30,
connectionId: 18,
minWireVersion: 0,
maxWireVersion: 20,
readOnly: false,
ok: 1
}

Next Steps (Optional)

You can use Cosign to verify MongoDB's signature for container images.

This procedure is optional. You do not need to verify MongoDB's signature to run MongoDB on Docker or any other containerized platform.

To verify MongoDB's container signature, perform the following steps:

1

Download and install Cosign

For installation instructions, see the Cosign GitHub repository.

2

Download the MongoDB Server container image's public key

curl https://cosign.mongodb.com/server.pem > server.pem
3

Verify the signature

Run the following command to verify the signature by tag:

COSIGN_REPOSITORY=docker.io/mongodb/signatures cosign verify --private-infrastructure --key=./server.pem docker.io/mongodb/mongodb-enterprise-server:latest

Learn More

For compatibility information, see Docker & MongoDB.