Docs Menu

Docs HomeMongoDB Manual

Install MongoDB Enterprise with Docker

On this page

  • About This Task
  • Before You Begin
  • Steps
  • Learn More

Important

The recommended solutions for using containers with MongoDB are:

  • For development and testing use the MongoDB Community Docker container. This image is maintained by MongoDB. The image contains the Community Edition of MongoDB.

  • For MongoDB Enterprise production installations, use the Enterprise Kubernetes Operator to deploy and manage MongoDB clusters within Kubernetes.

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:

  • Quickly set up a deployment.

  • Avoid editing configuration files.

  • Test features from multiple versions of MongoDB.

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.

Install Docker.

Install mongosh.

1
docker pull mongodb/mongodb-enterprise-server:latest
2
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

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
mongosh --port 27017
5

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
}

For compatibility information, see Docker & MongoDB.

←  Install MongoDB Enterprise on Windows using msiexec.exeUpgrade MongoDB Community to MongoDB Enterprise →
Share Feedback
© 2023 MongoDB, Inc.

About

  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2023 MongoDB, Inc.