Docs Menu

Install MongoDB Enterprise with Docker

Important

The recommended solutions for using containers with MongoDB are:

  • For development and testing use the MongoDB Community Docker container. This image is supported by MongoDB. The image contains the Community Edition of MongoDB.
  • For MongoDB Enterprise production installations, use MongoDB Ops Manager to configure Docker containers and Kubernetes.

To manually configure MongoDB Enterprise with Docker, follow the instructions on this page.

A full description of Docker is beyond the scope of this documentation. This page assumes prior knowledge of Docker.

This documentation only describes installing MongoDB Enterprise with Docker, and does not replace other resources on Docker. We encourage you to thoroughly familiarize yourself with Docker and its related subject matter before installing MongoDB Enterprise with Docker.

Important

This procedure uses the official mongo image. The image is supported by MongoDB.

The MongoDB community may contribute additional container images. For a listing of all available images, see the repositiory.

Install Docker and set up a Docker Hub account before creating a MongoDB Enterprise Docker image.

1

Set MONGODB_VERSION to a MongoDB major version:

export MONGODB_VERSION=5.0

Download the build files from the Docker Hub mongo project:

curl -O --remote-name-all https://raw.githubusercontent.com/docker-library/mongo/master/$MONGODB_VERSION/{Dockerfile,docker-entrypoint.sh}
2

Use the downloaded build files to create a Docker container image wrapped around MongoDB Enterprise. Set DOCKER_USERNAME to your Docker Hub username.

export DOCKER_USERNAME=username
chmod 755 ./docker-entrypoint.sh
docker build --build-arg MONGO_PACKAGE=mongodb-enterprise --build-arg MONGO_REPO=repo.mongodb.com -t $DOCKER_USERNAME/mongo-enterprise:$MONGODB_VERSION .
3

Verify that the image was created:

docker images $DOCKER_USERNAME/mongo-enterprise:$MONGODB_VERSION

The output should resemble:

REPOSITORY TAG IMAGE ID CREATED SIZE
username/mongo-enterprise 5.0 bf82d2c5f58d 19 seconds ago 952MB
4

The following commands:

  • Run a container using the mongo-enterprise Docker image.
  • Run mongosh inside the container to verify the MongoDB version.
docker run --name mongoEnt -itd $DOCKER_USERNAME/mongo-enterprise:$MONGODB_VERSION
docker exec -it mongoEnt /usr/bin/mongosh --eval "db.version()" | grep "Using Mongo"

The output should resemble:

60fbcf88c855e9ae41210422a083314b21a42661a28d970a078ea08ab8bcb06d
Using MongoDB: 5.0.7
Using Mongosh: 1.3.1

The displayed values are the:

  • container ID
  • MongoDB server version
  • mongosh version

Optionally, you can push your Docker image to a remote repository, like Docker Hub, to use the image on other host machines. If you push the image to Docker Hub, you can then run docker pull for each host machine on which you want to install MongoDB Enterprise via Docker. For complete guidance on using docker pull, reference its documentation here.

1

The following command displays your local Docker images:

docker images

You should see your MongoDB Enterprise image in the command output. If you do not, try Create a Docker Image with MongoDB Enterprise.

2

Push your local MongoDB Enterprise image to your remote Docker Hub account.

docker login
docker push $DOCKER_USERNAME/mongo-enterprise:$MONGODB_VERSION

If you log into the Docker Hub site, you should see the image listed under your repositories.

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

About

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